diff --git a/src/backend/wayland/handlers/compositor.rs b/src/backend/wayland/handlers/compositor.rs index 4d826725..235c65d3 100644 --- a/src/backend/wayland/handlers/compositor.rs +++ b/src/backend/wayland/handlers/compositor.rs @@ -15,9 +15,13 @@ impl CompositorHandler for WaylandState { &mut self, _conn: &Connection, _qh: &QueueHandle, - _surface: &wl_surface::WlSurface, + surface: &wl_surface::WlSurface, new_factor: i32, ) { + if !self.surface.is_surface(surface) { + return; + } + let scale = new_factor.max(1); debug!("Scale factor changed to {}", scale); self.surface.set_scale(scale); @@ -37,9 +41,13 @@ impl CompositorHandler for WaylandState { &mut self, _conn: &Connection, _qh: &QueueHandle, - _surface: &wl_surface::WlSurface, + surface: &wl_surface::WlSurface, _new_transform: wl_output::Transform, ) { + if !self.surface.is_surface(surface) { + return; + } + debug!("Transform changed"); } @@ -47,9 +55,13 @@ impl CompositorHandler for WaylandState { &mut self, _conn: &Connection, qh: &QueueHandle, - _surface: &wl_surface::WlSurface, + surface: &wl_surface::WlSurface, time: u32, ) { + if !self.surface.is_surface(surface) { + return; + } + debug!( "Frame callback received (time: {}ms), clearing frame_callback_pending", time @@ -92,9 +104,13 @@ impl CompositorHandler for WaylandState { &mut self, _conn: &Connection, _qh: &QueueHandle, - _surface: &wl_surface::WlSurface, + surface: &wl_surface::WlSurface, output: &wl_output::WlOutput, ) { + if !self.surface.is_surface(surface) { + return; + } + debug!("Surface entered output"); let previous_output = self.surface.current_output(); @@ -226,9 +242,13 @@ impl CompositorHandler for WaylandState { &mut self, _conn: &Connection, _qh: &QueueHandle, - _surface: &wl_surface::WlSurface, + surface: &wl_surface::WlSurface, output: &wl_output::WlOutput, ) { + if !self.surface.is_surface(surface) { + return; + } + debug!("Surface left output"); self.surface.clear_output(output); if self.surface.current_output().is_none() { diff --git a/src/backend/wayland/surface.rs b/src/backend/wayland/surface.rs index 391212d8..826ec139 100644 --- a/src/backend/wayland/surface.rs +++ b/src/backend/wayland/surface.rs @@ -10,7 +10,10 @@ use smithay_client_toolkit::{ shell::{WaylandSurface, wlr_layer::LayerSurface, xdg::window::Window}, shm::{Shm, slot::SlotPool}, }; -use wayland_client::protocol::{wl_output, wl_surface}; +use wayland_client::{ + Proxy, + protocol::{wl_output, wl_surface}, +}; /// The active shell role for the surface. pub enum SurfaceKind { @@ -86,6 +89,14 @@ impl SurfaceState { self.wl_surface.as_ref() } + /// Returns true if the provided wl_surface belongs to this overlay surface state. + pub fn is_surface(&self, surface: &wl_surface::WlSurface) -> bool { + self.wl_surface + .as_ref() + .map(|current| current.id() == surface.id()) + .unwrap_or(false) + } + /// Returns the mutable layer surface, if initialized. pub fn layer_surface_mut(&mut self) -> Option<&mut LayerSurface> { match &mut self.kind {