diff --git a/src/shell/mod.rs b/src/shell/mod.rs index e2809861..1512ab49 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -262,6 +262,7 @@ pub struct PendingLayer { pub struct Shell { pub workspaces: Workspaces, + // Can't make this into a HashSet. See https://github.com/pop-os/cosmic-comp/pull/1902 pub pending_windows: Vec, pub pending_layers: Vec, pub pending_activations: HashMap, diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index 4e034850..0826db76 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -44,13 +44,21 @@ impl XdgShellHandler for State { fn new_toplevel(&mut self, surface: ToplevelSurface) { let mut shell = self.common.shell.write(); let seat = shell.seats.last_active().clone(); - let window = CosmicSurface::from(surface); - shell.pending_windows.push(PendingWindow { - surface: window, - seat, - fullscreen: None, - maximized: false, - }); + + if shell + .pending_windows + .iter() + .find(|w| &w.surface == &surface) + .is_none() + { + let surface = CosmicSurface::from(surface); + shell.pending_windows.push(PendingWindow { + surface, + seat, + fullscreen: None, + maximized: false, + }) + } // We will position the window after the first commit, when we know its size hints } diff --git a/src/xwayland.rs b/src/xwayland.rs index 2cd789de..e47879cf 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -808,14 +808,20 @@ impl XwmHandler for State { *context, ); } - - let surface = CosmicSurface::from(window); - shell.pending_windows.push(PendingWindow { - surface, - seat, - fullscreen: None, - maximized: false, - }); + if shell + .pending_windows + .iter() + .find(|w| w.surface == window) + .is_none() + { + let surface = CosmicSurface::from(window); + shell.pending_windows.push(PendingWindow { + surface, + seat, + fullscreen: None, + maximized: false, + }) + } } fn map_window_notify(&mut self, _xwm: XwmId, surface: X11Surface) { @@ -875,6 +881,11 @@ impl XwmHandler for State { let seat = shell.seats.last_active().clone(); if let Some(pending) = shell.unmap_surface(&window, &seat, &mut self.common.toplevel_info_state) + && shell + .pending_windows + .iter() + .find(|w| &w.surface == &pending.surface) + .is_none() { shell.pending_windows.push(pending); }