From 4ed3aceefc8069f2ddf822a46bdf83fcba9b08cc Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 27 Jan 2023 18:15:54 +0100 Subject: [PATCH] shell: Don't annouce toplevels before they have contents --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/shell/mod.rs | 1 + src/wayland/handlers/xdg_shell/mod.rs | 1 - src/xwayland.rs | 37 +++++++++++++++++++-------- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c9721c3..78bf6d65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3282,7 +3282,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/pop-os/smithay?rev=217e0a4114#217e0a41148ad073e2b34fc8861c0532828e941f" +source = "git+https://github.com/pop-os/smithay?rev=406a40d6ec#406a40d6ec09723d8f1c73f3b7c9d62494cdbd13" dependencies = [ "appendlist", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 7d2094bc..0659c7ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,4 +70,4 @@ debug = true lto = "fat" [patch."https://github.com/Smithay/smithay.git"] -smithay = { git = "https://github.com/pop-os/smithay", rev = "217e0a4114" } +smithay = { git = "https://github.com/pop-os/smithay", rev = "406a40d6ec" } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 25ba8f4c..3d9927dc 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1059,6 +1059,7 @@ impl Shell { let (window, seat) = state.common.shell.pending_windows.remove(pos); let workspace = state.common.shell.workspaces.active_mut(output); + state.common.shell.toplevel_info_state.new_toplevel(&window); state .common .shell diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index b8ddf58e..e09f567b 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -37,7 +37,6 @@ impl XdgShellHandler for State { fn new_toplevel(&mut self, surface: ToplevelSurface) { let seat = self.common.last_active_seat().clone(); let window = CosmicSurface::Wayland(Window::new(surface)); - self.common.shell.toplevel_info_state.new_toplevel(&window); self.common.shell.pending_windows.push((window, seat)); // 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 12762ced..9c1cff21 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -94,6 +94,7 @@ impl State { self.common.event_loop_handle.clone(), None, std::iter::empty::<(OsString, OsString)>(), + //vec![("WAYLAND_DEBUG", "client")].into_iter(), |map| { if let Some(node) = drm_node { map.insert_if_missing(|| node); @@ -141,31 +142,45 @@ impl XwmHandler for Data { err ); } + + let surface = CosmicSurface::X11(window.clone()); if self .state .common .shell - .element_for_surface(&CosmicSurface::X11(window.clone())) + .element_for_surface(&surface) .is_some() { return; } - let window = CosmicSurface::X11(window); - self.state - .common - .shell - .toplevel_info_state - .new_toplevel(&window); - let seat = self.state.common.last_active_seat().clone(); - let output = seat.active_output(); self.state .common .shell .pending_windows - .push((window.clone(), seat)); - Shell::map_window(&mut self.state, &window, &output); + .push((surface, seat)); + } + + fn map_window_notify(&mut self, _xwm: XwmId, surface: X11Surface) { + if let Some((window, seat)) = self + .state + .common + .shell + .pending_windows + .iter() + .find(|(window, _)| { + if let CosmicSurface::X11(window) = window { + window == &surface + } else { + false + } + }) + .cloned() + { + let output = seat.active_output(); + Shell::map_window(&mut self.state, &window, &output); + } } fn mapped_override_redirect_window(&mut self, _xwm: XwmId, window: X11Surface) {