diff --git a/src/api.rs b/src/api.rs index b763407..7d9a8f4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -731,6 +731,8 @@ impl tag_service_server::TagService for TagService { return; }; + state.fixup_xwayland_internal_z_indices(); + state.request_layout(&output); state.update_focus(&output); state.schedule_render(&output); @@ -758,6 +760,8 @@ impl tag_service_server::TagService for TagService { tag.set_active(true, state); }); + state.fixup_xwayland_internal_z_indices(); + state.request_layout(&output); state.update_focus(&output); state.schedule_render(&output); diff --git a/src/focus.rs b/src/focus.rs index 6693541..6f714ed 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -73,6 +73,8 @@ impl State { self.z_index_stack.retain(|win| win != &window); self.z_index_stack.push(window); + + self.fixup_xwayland_internal_z_indices(); } /// Get the currently focused output, or the first mapped output if there is none, or None. diff --git a/src/handlers/xwayland.rs b/src/handlers/xwayland.rs index b85000d..1b02bb8 100644 --- a/src/handlers/xwayland.rs +++ b/src/handlers/xwayland.rs @@ -22,7 +22,7 @@ use smithay::{ X11Surface, X11Wm, XwmHandler, }, }; -use tracing::{debug, error, trace}; +use tracing::{debug, error, trace, warn}; use crate::{ focus::keyboard::KeyboardFocusTarget, @@ -510,6 +510,28 @@ impl XwmHandler for State { } } +impl State { + pub fn fixup_xwayland_internal_z_indices(&mut self) { + let Some(xwm) = self.xwm.as_mut() else { + return; + }; + + let x11_wins = self + .space + .elements() + .filter(|win| win.is_on_active_tag()) + .filter_map(|win| win.x11_surface()) + .cloned() + .collect::>(); + + for x11_win in x11_wins { + if let Err(err) = xwm.raise_window(&x11_win) { + warn!("Failed to raise xwayland window: {err}"); + } + } + } +} + /// Make assumptions on whether or not the surface should be floating. /// /// This logic is taken from the Sway function `wants_floating` in sway/desktop/xwayland.c.