Update internal xwm window layering

This commit is contained in:
Ottatop 2024-04-19 15:02:16 -05:00
parent 9af11d7b6a
commit 8df5682328
3 changed files with 29 additions and 1 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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::<Vec<_>>();
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.