xwayland: Don't allow spurious map_requests to map windows twice

This commit is contained in:
Victoria Brekenfeld 2025-07-01 14:22:25 +02:00 committed by Victoria Brekenfeld
parent 83ed79af16
commit 5f97691ce5
2 changed files with 32 additions and 2 deletions

View file

@ -1961,6 +1961,33 @@ impl Shell {
})
}
pub fn is_surface_mapped<S>(&self, surface: &S) -> bool
where
CosmicSurface: PartialEq<S>,
{
self.workspaces.sets.values().any(|set| {
set.minimized_windows
.iter()
.any(|w| w.windows().any(|s| &s == surface))
|| set
.sticky_layer
.mapped()
.any(|m| m.windows().any(|(s, _)| &s == surface))
|| set.workspaces.iter().any(|w| {
w.get_fullscreen().is_some_and(|s| s == surface)
|| w.minimized_windows
.iter()
.any(|m| m.windows().any(|s| &s == surface))
|| w.floating_layer
.mapped()
.any(|m| m.windows().any(|(s, _)| &s == surface))
|| w.tiling_layer
.mapped()
.any(|(m, _)| m.windows().any(|(s, _)| &s == surface))
})
})
}
pub fn space_for(&self, mapped: &CosmicMapped) -> Option<&Workspace> {
self.workspaces.spaces().find(|workspace| {
workspace.mapped().any(|m| m == mapped)

View file

@ -734,8 +734,11 @@ impl XwmHandler for State {
let mut shell = self.common.shell.write();
let startup_id = window.startup_id();
// TODO: Not correct for fullscreen (and minimized?)
if shell.element_for_surface(&window).is_some() {
if shell.is_surface_mapped(&window) {
warn!(
?window,
"Got map_request for already mapped window? Ignoring"
);
return;
}