From 47d2344123389dd1636c71948c2f42afd034f999 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Mar 2026 21:26:54 +0000 Subject: [PATCH 1/2] fix: explicit restack of XWayland surfaces in WaylandState::restack Added `xwm.raise_window(surface)` inside `WaylandState::restack` to ensure that XWayland windows visually update their Z-order when focus changes occur in layouts like monocle. Without this, Smithay would internally reorder the surfaces but X11 clients would continue compositing their buffers based on stale X11 stacking orders. Co-authored-by: paperbenni <15818888+paperbenni@users.noreply.github.com> --- src/backend/wayland/compositor/window/management.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/wayland/compositor/window/management.rs b/src/backend/wayland/compositor/window/management.rs index 1ce97e30..5d28d217 100644 --- a/src/backend/wayland/compositor/window/management.rs +++ b/src/backend/wayland/compositor/window/management.rs @@ -54,6 +54,13 @@ impl WaylandState { // Focus / activation is managed by `set_focus`, so we pass `false` // here to avoid overriding the focus state visually. self.space.raise_element(&element, false); + + // XWayland requires us to explicitly restack the X11 surface so X clients draw correctly + if let Some(surface) = element.x11_surface() + && let Some(xwm) = self.xwm.as_mut() + { + let _ = xwm.raise_window(surface); + } } } self.raise_unmanaged_x11_windows(); From d4d79b655047dad6e2f00f807c7ca84c52a03bc5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:39:10 +0000 Subject: [PATCH 2/2] fix: add explicit restack and error logging for XWayland surfaces Updated `WaylandState::restack` to explicitly restack X11 surfaces via `xwm.raise_window(surface)`. Also added error logging when this restack request fails, which will assist with diagnosing any future XWayland depth/stacking-related visual bugs in overlapping or monocle layouts. Co-authored-by: paperbenni <15818888+paperbenni@users.noreply.github.com> --- src/backend/wayland/compositor/window/management.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/wayland/compositor/window/management.rs b/src/backend/wayland/compositor/window/management.rs index 5d28d217..cecefaf3 100644 --- a/src/backend/wayland/compositor/window/management.rs +++ b/src/backend/wayland/compositor/window/management.rs @@ -41,7 +41,9 @@ impl WaylandState { if let Some(surface) = element.x11_surface() && let Some(xwm) = self.xwm.as_mut() { - let _ = xwm.raise_window(surface); + if let Err(e) = xwm.raise_window(surface) { + log::warn!("Failed to restack X11 surface for window {:?}: {}", window, e); + } } } self.raise_unmanaged_x11_windows(); @@ -59,7 +61,9 @@ impl WaylandState { if let Some(surface) = element.x11_surface() && let Some(xwm) = self.xwm.as_mut() { - let _ = xwm.raise_window(surface); + if let Err(e) = xwm.raise_window(surface) { + log::warn!("Failed to restack X11 surface for window {:?}: {}", window, e); + } } } }