srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/winit
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-02-04 23:21:00 +0200
committersrdusr <[email protected]>2025-02-04 23:21:00 +0200
commit31942ff440c6039b943b4975714dca25372f80c5 (patch)
tree420fa5be87eb03fd3b898f3c86402380be3514cf /crates/wayland/src/winit
parentdae1617a8b7ee7c40beb452046c5ec84e69931ee (diff)
downloadsrdwm-31942ff440c6039b943b4975714dca25372f80c5.tar.gz
srdwm-31942ff440c6039b943b4975714dca25372f80c5.zip
Fix CSD windows rendering with a wallpaper-visible gap at their corner
srdwm never read xdg_surface.set_window_geometry anywhere. A CSD client (GTK4/Firefox) declares its real visible content as a sub-rect inset within a larger buffer that also reserves an invisible shadow margin - that margin stays reserved in the buffer even once the tiled-state hint tells the client to stop drawing the shadow itself. Every render path was positioning content at the client's raw buffer origin instead of subtracting that declared offset, leaving the margin's width/height as a gap with wallpaper visible through it at the window's top-left corner. Confirmed by pixel-diffing the gap against the real wallpaper at that exact screen position: an exact match, ruling out "just the client's own dark theme." Fixed in three places that have to move together: udev/render.rs and winit/render.rs's content-positioning code, and sync_geometry's space.map_element call. That last one matters as much as the other two - it's what smithay's Space (and therefore click hit-testing) reads, so a render-only fix would have traded a visible gap for an invisible, same-size hit-test offset in the other direction. Also applied to the new capture-workspace off-screen render for the same reason. This likely also explains real dropdown/context-menu misplacement (and the clicks landing on the wrong spot) in CSD apps: popup positioning anchors against the same window position this fix corrects.
Diffstat (limited to 'crates/wayland/src/winit')
-rw-r--r--crates/wayland/src/winit/render.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/wayland/src/winit/render.rs b/crates/wayland/src/winit/render.rs
index 735ff34..ec4fd69 100644
--- a/crates/wayland/src/winit/render.rs
+++ b/crates/wayland/src/winit/render.rs
@@ -247,7 +247,15 @@ impl WaylandPlatform {
if let Some(dwindow) = self.state.id_to_window.get(&id) {
if let Some(surface) = crate::elements::window_wl_surface(dwindow) {
let band = if w.decorated { srdwm_core::TITLEBAR_HEIGHT as i32 } else { 0 };
- let pos = (geom.x, geom.y + band);
+ // See the matching fix in `udev/render.rs`'s render loop
+ // for the full explanation: a CSD client's own
+ // `set_window_geometry` offset (its declared visible
+ // content within a larger buffer that also reserves an
+ // invisible shadow margin) was never subtracted, so
+ // that margin's worth of gap showed through at this
+ // window's top-left corner.
+ let content_offset = dwindow.geometry().loc;
+ let pos = (geom.x - content_offset.x, geom.y + band - content_offset.y);
let rounded = rounded_corners_enabled.then_some(self.state.rounded_corners_program.as_ref()).flatten().and_then(|program| {
let corners = if w.decorated { crate::rounded_corners::RoundedCorners::BOTTOM_ONLY } else { crate::rounded_corners::RoundedCorners::ALL };
crate::rounded_corners::rounded_content_element(renderer, program, &surface, pos, w.opacity, w.corner_radius as f32, corners)