Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/backend/wayland/handlers/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ impl CompositorHandler for WaylandState {
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_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);
Expand All @@ -37,19 +41,27 @@ impl CompositorHandler for WaylandState {
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_surface: &wl_surface::WlSurface,
surface: &wl_surface::WlSurface,
_new_transform: wl_output::Transform,
) {
if !self.surface.is_surface(surface) {
return;
}

debug!("Transform changed");
}

fn frame(
&mut self,
_conn: &Connection,
qh: &QueueHandle<Self>,
_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
Expand Down Expand Up @@ -92,9 +104,13 @@ impl CompositorHandler for WaylandState {
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_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();
Expand Down Expand Up @@ -226,9 +242,13 @@ impl CompositorHandler for WaylandState {
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_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() {
Expand Down
13 changes: 12 additions & 1 deletion src/backend/wayland/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading