From a5e8b39e4f3cdadb0e7be19daac60a761eeee968 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sat, 19 Jul 2025 22:26:57 +0200 Subject: [PATCH] toplevel: store if ancestor is fullscreen --- src/tree/container.rs | 10 ++++++++++ src/tree/containing.rs | 3 +++ src/tree/toplevel.rs | 31 +++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/tree/container.rs b/src/tree/container.rs index bcf01e7a..14e5aac1 100644 --- a/src/tree/container.rs +++ b/src/tree/container.rs @@ -2108,6 +2108,10 @@ impl ContainingNode for ContainerNode { fn cnode_get_float(self: Rc) -> Option> { self.tl_data().float.get() } + + fn cnode_self_or_ancestor_fullscreen(&self) -> bool { + self.tl_data().self_or_ancestor_is_fullscreen.get() + } } impl ToplevelNodeBase for ContainerNode { @@ -2229,6 +2233,12 @@ impl ToplevelNodeBase for ContainerNode { child.node.tl_set_float(float); } } + + fn tl_mark_ancestor_fullscreen_ext(&self, fullscreen: bool) { + for child in self.children.iter() { + child.node.tl_mark_ancestor_fullscreen(fullscreen); + } + } } fn direction_to_split(dir: Direction) -> (ContainerSplit, bool) { diff --git a/src/tree/containing.rs b/src/tree/containing.rs index c8b2d9ba..3a8c0f67 100644 --- a/src/tree/containing.rs +++ b/src/tree/containing.rs @@ -41,4 +41,7 @@ pub trait ContainingNode: Node { fn cnode_get_float(self: Rc) -> Option> { None } + fn cnode_self_or_ancestor_fullscreen(&self) -> bool { + false + } } diff --git a/src/tree/toplevel.rs b/src/tree/toplevel.rs index 33def51e..f472374e 100644 --- a/src/tree/toplevel.rs +++ b/src/tree/toplevel.rs @@ -70,6 +70,8 @@ pub trait ToplevelNode: ToplevelNodeBase { fn tl_pinned(&self) -> bool; fn tl_set_pinned(&self, self_pinned: bool, pinned: bool); fn tl_set_float(&self, float: Option<&Rc>); + fn tl_mark_ancestor_fullscreen(&self, fullscreen: bool); + fn tl_mark_fullscreen(&self, fullscreen: bool); } impl ToplevelNode for T { @@ -110,6 +112,9 @@ impl ToplevelNode for T { fn tl_set_parent(&self, parent: Rc) { let data = self.tl_data(); + if !data.is_fullscreen.get() { + self.tl_mark_ancestor_fullscreen(parent.cnode_self_or_ancestor_fullscreen()); + } let parent_was_none = data.parent.set(Some(parent.clone())).is_none(); if parent_was_none { data.mapped_during_iteration.set(data.state.eng.iteration()); @@ -227,6 +232,22 @@ impl ToplevelNode for T { self.tl_data().float.set(float.cloned()); self.tl_push_float(float); } + + fn tl_mark_ancestor_fullscreen(&self, fullscreen: bool) { + let old = self + .tl_data() + .self_or_ancestor_is_fullscreen + .replace(fullscreen); + if old == fullscreen { + return; + } + self.tl_mark_ancestor_fullscreen_ext(fullscreen); + } + + fn tl_mark_fullscreen(&self, fullscreen: bool) { + self.tl_data().is_fullscreen.set(fullscreen); + self.tl_mark_ancestor_fullscreen(fullscreen); + } } pub trait ToplevelNodeBase: Node { @@ -290,6 +311,10 @@ pub trait ToplevelNodeBase: Node { fn tl_push_float(&self, float: Option<&Rc>) { let _ = float; } + + fn tl_mark_ancestor_fullscreen_ext(&self, fullscreen: bool) { + let _ = fullscreen; + } } pub struct FullscreenedData { @@ -346,6 +371,7 @@ pub struct ToplevelData { pub float_height: Cell, pub pinned: Cell, pub is_fullscreen: Cell, + pub self_or_ancestor_is_fullscreen: Cell, pub fullscrceen_data: RefCell>, pub workspace: CloneCell>>, pub title: RefCell, @@ -401,6 +427,7 @@ impl ToplevelData { float_height: Default::default(), pinned: Cell::new(false), is_fullscreen: Default::default(), + self_or_ancestor_is_fullscreen: Default::default(), fullscrceen_data: Default::default(), workspace: Default::default(), title: RefCell::new(title), @@ -731,7 +758,7 @@ impl ToplevelData { workspace: ws.clone(), }); drop(data); - self.is_fullscreen.set(true); + node.tl_mark_fullscreen(true); self.property_changed(TL_CHANGED_FULLSCREEN); node.tl_set_parent(ws.clone()); ws.set_fullscreen_node(&node); @@ -758,7 +785,7 @@ impl ToplevelData { return; } }; - self.is_fullscreen.set(false); + node.tl_mark_fullscreen(false); self.property_changed(TL_CHANGED_FULLSCREEN); match fd.workspace.fullscreen.get() { None => {