From 44f328dc510b9251578f7b350b5f606b7c89b828 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 2 Oct 2025 20:24:11 -0700 Subject: [PATCH] Set "suspended" when a surface is minimized This seems for an SDL XWayland client to restore fullscreen after unminimize, it needs to see the `_NET_WM_STATE_FOCUSED` state get set and unset. This is a somewhat awkward way to do this. I'm not sure if the Wayland `suspended` flag should be treated as equivalent to `_NET_WM_STATE_FOCUSED`? If it's meant to be, the way it's defined in the protocol doesn't quite seem right. https://github.com/pop-os/cosmic-comp/issues/1510 --- src/shell/element/surface.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index b97856030..25f1ee726 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -103,6 +103,9 @@ struct Minimized(AtomicBool); #[derive(Default)] struct Sticky(AtomicBool); +#[derive(Default)] +struct Suspended(AtomicBool); + #[derive(Default)] struct GlobalGeometry(Mutex>>); @@ -448,6 +451,7 @@ impl CosmicSurface { let _ = surface.set_mapped(true); } } + self.update_suspended(); } pub fn is_sticky(&self) -> bool { @@ -466,7 +470,16 @@ impl CosmicSurface { .store(sticky, Ordering::SeqCst); } - pub fn set_suspended(&self, suspended: bool) { + fn update_suspended(&self) { + let minimized = self.is_minimized(); + let suspended = self + .0 + .user_data() + .get_or_insert_threadsafe(Minimized::default) + .0 + .load(Ordering::SeqCst); + + let suspended = minimized || suspended; match self.0.underlying_surface() { WindowSurface::Wayland(window) => window.with_pending_state(|state| { if suspended { @@ -481,6 +494,15 @@ impl CosmicSurface { } } + pub fn set_suspended(&self, suspended: bool) { + self.0 + .user_data() + .get_or_insert_threadsafe(Suspended::default) + .0 + .store(suspended, Ordering::SeqCst); + self.update_suspended(); + } + pub fn min_size_without_ssd(&self) -> Option> { match self.0.underlying_surface() { WindowSurface::Wayland(toplevel) => {