From 1043058179fba46a7caa7ba9372c42c3c8e059b3 Mon Sep 17 00:00:00 2001 From: sachahjkl Date: Mon, 9 Nov 2026 11:58:27 +0100 Subject: [PATCH] Announce a toplevel to taskbars with its first buffer ShojiWM made the foreign-toplevel handles (ext-foreign-toplevel-list, wlr-foreign-toplevel-management, the Plasma window list) when a toplevel's role was made. A program that makes its window and never shows it, such as one started hidden in the notification area, then had a taskbar button for a window nobody could see. The handles now come with the toplevel's first buffer, in the commit handler; the install is idempotent, so each commit of a shown toplevel can ask. --- src/shojiwm_lib/src/handlers/compositor.rs | 12 ++++++++++++ src/shojiwm_lib/src/handlers/xdg_shell.rs | 7 +++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/shojiwm_lib/src/handlers/compositor.rs b/src/shojiwm_lib/src/handlers/compositor.rs index 5fcd8b8ee..313a6879f 100644 --- a/src/shojiwm_lib/src/handlers/compositor.rs +++ b/src/shojiwm_lib/src/handlers/compositor.rs @@ -690,6 +690,18 @@ impl CompositorHandler for ShojiWM { window.on_commit(); // Before the snapshot below, which derives the window position from the location. self.keep_client_origin_across_geometry_change(&window); + // A toplevel is announced on the foreign-toplevel protocols once it has a buffer, + // not when its role is made: one that never shows anything (started hidden) is no + // window for a taskbar. Idempotent, so every commit of a shown window can ask. + if let Some(toplevel) = window.toplevel() + && smithay::backend::renderer::utils::with_renderer_surface_state( + toplevel.wl_surface(), + |state| state.buffer().is_some(), + ) + .unwrap_or(false) + { + self.install_foreign_toplevel(&window); + } // Title / app_id may have changed via xdg_toplevel set_title / // set_app_id between commits. sync_foreign_toplevel short-circuits // when nothing changed so this is cheap. diff --git a/src/shojiwm_lib/src/handlers/xdg_shell.rs b/src/shojiwm_lib/src/handlers/xdg_shell.rs index 77e9b6b72..506ac323f 100644 --- a/src/shojiwm_lib/src/handlers/xdg_shell.rs +++ b/src/shojiwm_lib/src/handlers/xdg_shell.rs @@ -146,10 +146,9 @@ impl XdgShellHandler for ShojiWM { self.space .map_element(window.clone(), initial_location, false); self.ensure_wayland_window_decoration_policy(&wl_surface); - // Announce the new toplevel on ext-foreign-toplevel-list-v1 so shells - // and the portal picker can see it. Has to happen after map so the - // initial title/app_id reads from xdg state succeed. - self.install_foreign_toplevel(&window); + // The foreign-toplevel handles come with the first buffer (the commit handler): a + // toplevel that never shows anything, such as a program started hidden in the + // notification area, is no window for a taskbar. if uses_xwayland_refresh_override { self.update_xwayland_refresh_override_for_window(&window, "xdg-toplevel-map"); }