Improve xwayland stacking logic
Some checks are pending
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run

Fixes a few bugs related to the pointer clicking through xwayland windows
This commit is contained in:
Ottatop 2024-08-06 13:38:50 -05:00
parent 63838fb649
commit f5aabd5b60
6 changed files with 23 additions and 19 deletions

2
Cargo.lock generated
View file

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

View file

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

View file

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

View file

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

View file

@ -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::<Vec<_>>();
.filter(|win| !win.is_x11_override_redirect())
.partition::<Vec<_>, _>(|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}");
}
}
}

View file

@ -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<WindowElement>,
pub popup_manager: PopupManager,