From 5505b25c81e38331902cca620d78ac2cac34badb Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Mon, 27 Jul 2026 20:53:57 +0200 Subject: [PATCH] feat: allow XWayland window to start minimized --- src/shell/mod.rs | 13 +++++++++++-- src/wayland/handlers/xdg_shell/mod.rs | 1 + src/xwayland.rs | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 39d692e2d..60354aacc 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -254,6 +254,7 @@ pub struct PendingWindow { pub surface: CosmicSurface, pub seat: Seat, pub fullscreen: Option, + pub minimized: bool, pub maximized: bool, pub sticky: bool, } @@ -2828,6 +2829,7 @@ impl Shell { surface: window, seat, fullscreen: output, + minimized: should_be_minimized, maximized: should_be_maximized, sticky: mut should_be_sticky, } = self.pending_windows.remove(pos); @@ -2911,6 +2913,7 @@ impl Shell { if let Some(FocusTarget::Window(focused)) = maybe_focused && let Some(stack) = focused.stack_ref() && !is_dialog + && !should_be_minimized && !should_be_maximized && !(workspace.is_tiled(&focused.active_window()) && floating_exception) { @@ -2960,8 +2963,13 @@ impl Shell { self.maximize_request(&mapped, &seat, false, loop_handle); } - let new_target = if (workspace_output == seat.active_output() - && active_handle == workspace_handle) + if should_be_minimized { + self.minimize_request(&window); + } + + let new_target = if should_be_minimized { + None + } else if (workspace_output == seat.active_output() && active_handle == workspace_handle) || should_be_sticky { // TODO: enforce focus stealing prevention by also checking the same rules as for the else case. @@ -3085,6 +3093,7 @@ impl Shell { surface, seat: seat.clone(), fullscreen: None, + minimized: false, maximized: false, sticky: false, }); diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index b8288019b..1f498371e 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -50,6 +50,7 @@ impl XdgShellHandler for State { surface, seat, fullscreen: None, + minimized: false, maximized: false, sticky: false, }) diff --git a/src/xwayland.rs b/src/xwayland.rs index 83978b6e5..cfa9f349b 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -808,6 +808,7 @@ impl XwmHandler for State { ); } let fullscreen = window.is_fullscreen().then(|| seat.active_output()); + let minimized = window.is_hidden(); let maximized = window.is_maximized(); if let Some(pending) = shell .pending_windows @@ -816,6 +817,7 @@ impl XwmHandler for State { { pending.seat = seat; pending.fullscreen = fullscreen; + pending.minimized = minimized; pending.maximized = maximized; } else { let surface = CosmicSurface::from(window); @@ -823,6 +825,7 @@ impl XwmHandler for State { surface, seat, fullscreen, + minimized, maximized, sticky: false, })