diff --git a/Cargo.lock b/Cargo.lock index 44731ec..920ce46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2407,7 +2407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] diff --git a/src/api.rs b/src/api.rs index 8405e9b..fe9fdb1 100644 --- a/src/api.rs +++ b/src/api.rs @@ -856,7 +856,7 @@ impl tag_service_server::TagService for TagService { }); } - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); state.pinnacle.begin_layout_transaction(&output); state.pinnacle.request_layout(&output); @@ -909,7 +909,7 @@ impl tag_service_server::TagService for TagService { } }); - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); state.pinnacle.begin_layout_transaction(&output); state.pinnacle.request_layout(&output); @@ -957,7 +957,7 @@ impl tag_service_server::TagService for TagService { }); } - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); AddResponse { tag_ids } }) @@ -999,7 +999,7 @@ impl tag_service_server::TagService for TagService { } } - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); }) .await } diff --git a/src/api/window.rs b/src/api/window.rs index 4ad3e8f..bd3dbf7 100644 --- a/src/api/window.rs +++ b/src/api/window.rs @@ -359,7 +359,7 @@ impl window_service_server::WindowService for WindowService { state.schedule_render(&output); - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); }) .await } @@ -427,7 +427,7 @@ impl window_service_server::WindowService for WindowService { state.schedule_render(&output); - state.pinnacle.fixup_xwayland_window_layering(); + state.pinnacle.update_xwayland_stacking_order(); }) .await } diff --git a/src/focus.rs b/src/focus.rs index 12f07ce..6344f4b 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -86,7 +86,7 @@ impl Pinnacle { self.z_index_stack.retain(|win| win != window); self.z_index_stack.push(window); - self.fixup_xwayland_window_layering(); + self.update_xwayland_stacking_order(); } /// 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 d84af9c..ad75caf 100644 --- a/src/handlers/xwayland.rs +++ b/src/handlers/xwayland.rs @@ -452,23 +452,26 @@ impl State { } impl Pinnacle { - pub fn fixup_xwayland_window_layering(&mut self) { + pub fn update_xwayland_stacking_order(&mut self) { let Some(xwm) = self.xwm.as_mut() else { return; }; - let x11_wins = self - .windows + let (active_windows, non_active_windows) = self + .z_index_stack .iter() - .filter(|win| win.is_on_active_tag()) - .filter_map(|win| win.x11_surface()) - .cloned() - .collect::>(); + .filter(|win| !win.is_x11_override_redirect()) + .partition::, _>(|win| win.is_on_active_tag()); - for x11_win in x11_wins { - if let Err(err) = xwm.raise_window(&x11_win) { - warn!("Failed to raise xwayland window: {err}"); - } + let active_windows = active_windows.into_iter().flat_map(|win| win.x11_surface()); + let non_active_windows = non_active_windows + .into_iter() + .flat_map(|win| win.x11_surface()); + + if let Err(err) = + xwm.update_stacking_order_upwards(non_active_windows.chain(active_windows)) + { + warn!("Failed to update xwayland stacking order: {err}"); } } } diff --git a/src/state.rs b/src/state.rs index 0262f5a..5f2f3ab 100644 --- a/src/state.rs +++ b/src/state.rs @@ -138,6 +138,7 @@ pub struct Pinnacle { pub input_state: InputState, pub output_focus_stack: OutputFocusStack, + /// The z-index stack, bottom to top pub z_index_stack: Vec, pub popup_manager: PopupManager,