Skip to content

Commit 44f328d

Browse files
committed
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. #1510
1 parent 346f055 commit 44f328d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/shell/element/surface.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ struct Minimized(AtomicBool);
103103
#[derive(Default)]
104104
struct Sticky(AtomicBool);
105105

106+
#[derive(Default)]
107+
struct Suspended(AtomicBool);
108+
106109
#[derive(Default)]
107110
struct GlobalGeometry(Mutex<Option<Rectangle<i32, Global>>>);
108111

@@ -448,6 +451,7 @@ impl CosmicSurface {
448451
let _ = surface.set_mapped(true);
449452
}
450453
}
454+
self.update_suspended();
451455
}
452456

453457
pub fn is_sticky(&self) -> bool {
@@ -466,7 +470,16 @@ impl CosmicSurface {
466470
.store(sticky, Ordering::SeqCst);
467471
}
468472

469-
pub fn set_suspended(&self, suspended: bool) {
473+
fn update_suspended(&self) {
474+
let minimized = self.is_minimized();
475+
let suspended = self
476+
.0
477+
.user_data()
478+
.get_or_insert_threadsafe(Minimized::default)
479+
.0
480+
.load(Ordering::SeqCst);
481+
482+
let suspended = minimized || suspended;
470483
match self.0.underlying_surface() {
471484
WindowSurface::Wayland(window) => window.with_pending_state(|state| {
472485
if suspended {
@@ -481,6 +494,15 @@ impl CosmicSurface {
481494
}
482495
}
483496

497+
pub fn set_suspended(&self, suspended: bool) {
498+
self.0
499+
.user_data()
500+
.get_or_insert_threadsafe(Suspended::default)
501+
.0
502+
.store(suspended, Ordering::SeqCst);
503+
self.update_suspended();
504+
}
505+
484506
pub fn min_size_without_ssd(&self) -> Option<Size<i32, Logical>> {
485507
match self.0.underlying_surface() {
486508
WindowSurface::Wayland(toplevel) => {

0 commit comments

Comments
 (0)