1
0
Fork 0
forked from wry/wry

tree: restack floaters and popups on demand

This commit is contained in:
Julian Orth 2024-03-03 15:39:04 +01:00
parent 911591973e
commit 386d74f926
6 changed files with 52 additions and 6 deletions

View file

@ -328,6 +328,12 @@ impl XdgSurface {
popup.set_visible(visible); popup.set_visible(visible);
} }
} }
fn restack_popups(&self) {
for popup in self.popups.lock().values() {
popup.restack();
}
}
} }
object_base! { object_base! {

View file

@ -259,6 +259,16 @@ impl XdgPopup {
self.xdg.detach_node(); self.xdg.detach_node();
self.seat_state.destroy_node(self); self.seat_state.destroy_node(self);
} }
pub fn restack(&self) {
let state = &self.xdg.surface.client.state;
let dl = self.display_link.borrow();
if let Some(dl) = &*dl {
state.root.stacked.add_last_existing(dl);
}
self.xdg.restack_popups();
state.tree_changed();
}
} }
object_base! { object_base! {

View file

@ -634,6 +634,10 @@ impl ToplevelNodeBase for XdgToplevel {
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> { fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
Some(self.xdg.surface.clone()) Some(self.xdg.surface.clone())
} }
fn tl_restack_popups(&self) {
self.xdg.restack_popups();
}
} }
impl XdgSurfaceExt for XdgToplevel { impl XdgSurfaceExt for XdgToplevel {

View file

@ -759,6 +759,7 @@ impl ContainerNode {
} }
self.mono_child.set(Some(child.clone())); self.mono_child.set(Some(child.clone()));
child.node.tl_set_visible(true); child.node.tl_set_visible(true);
child.node.tl_restack_popups();
// log::info!("activate_child2"); // log::info!("activate_child2");
self.schedule_layout(); self.schedule_layout();
} }
@ -797,6 +798,7 @@ impl ContainerNode {
.clone() .clone()
.node_do_focus(&seat, Direction::Unspecified); .node_do_focus(&seat, Direction::Unspecified);
} }
child.node.tl_restack_popups();
} else { } else {
for child in self.children.iter() { for child in self.children.iter() {
child.node.tl_set_visible(true); child.node.tl_set_visible(true);
@ -1366,6 +1368,7 @@ impl ContainingNode for ContainerNode {
let mut body = None; let mut body = None;
if was_mc { if was_mc {
self.mono_child.set(Some(link.to_ref())); self.mono_child.set(Some(link.to_ref()));
link.node.tl_restack_popups();
body = Some(self.mono_body.get()); body = Some(self.mono_body.get());
} else if !have_mc { } else if !have_mc {
body = Some(link.body.get()); body = Some(link.body.get());
@ -1537,6 +1540,16 @@ impl ToplevelNodeBase for ContainerNode {
} }
self self
} }
fn tl_restack_popups(&self) {
if let Some(mc) = self.mono_child.get() {
mc.node.tl_restack_popups();
} else {
for child in self.children.iter() {
child.node.tl_restack_popups();
}
}
}
} }
fn direction_to_split(dir: Direction) -> (ContainerSplit, bool) { fn direction_to_split(dir: Direction) -> (ContainerSplit, bool) {

View file

@ -34,7 +34,7 @@ pub struct FloatNode {
pub state: Rc<State>, pub state: Rc<State>,
pub visible: Cell<bool>, pub visible: Cell<bool>,
pub position: Cell<Rect>, pub position: Cell<Rect>,
pub display_link: Cell<Option<LinkedNode<Rc<dyn StackedNode>>>>, pub display_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
pub workspace_link: Cell<Option<LinkedNode<Rc<dyn StackedNode>>>>, pub workspace_link: Cell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
pub workspace: CloneCell<Rc<WorkspaceNode>>, pub workspace: CloneCell<Rc<WorkspaceNode>>,
pub child: CloneCell<Option<Rc<dyn ToplevelNode>>>, pub child: CloneCell<Option<Rc<dyn ToplevelNode>>>,
@ -103,7 +103,7 @@ impl FloatNode {
state: state.clone(), state: state.clone(),
visible: Cell::new(ws.stacked_visible()), visible: Cell::new(ws.stacked_visible()),
position: Cell::new(position), position: Cell::new(position),
display_link: Cell::new(None), display_link: RefCell::new(None),
workspace_link: Cell::new(None), workspace_link: Cell::new(None),
workspace: CloneCell::new(ws.clone()), workspace: CloneCell::new(ws.clone()),
child: CloneCell::new(Some(child.clone())), child: CloneCell::new(Some(child.clone())),
@ -117,14 +117,13 @@ impl FloatNode {
attention_requested: Cell::new(false), attention_requested: Cell::new(false),
}); });
floater.pull_child_properties(); floater.pull_child_properties();
floater *floater.display_link.borrow_mut() = Some(state.root.stacked.add_last(floater.clone()));
.display_link
.set(Some(state.root.stacked.add_last(floater.clone())));
floater floater
.workspace_link .workspace_link
.set(Some(ws.stacked.add_last(floater.clone()))); .set(Some(ws.stacked.add_last(floater.clone())));
child.tl_set_parent(floater.clone()); child.tl_set_parent(floater.clone());
child.tl_set_visible(floater.visible.get()); child.tl_set_visible(floater.visible.get());
child.tl_restack_popups();
floater.schedule_layout(); floater.schedule_layout();
floater floater
} }
@ -389,6 +388,16 @@ impl FloatNode {
.cnode_child_attention_request_changed(self, false); .cnode_child_attention_request_changed(self, false);
} }
} }
fn restack(&self) {
if let Some(dl) = &*self.display_link.borrow() {
self.state.root.stacked.add_last_existing(&dl);
if let Some(tl) = self.child.get() {
tl.tl_restack_popups();
}
self.state.tree_changed();
}
}
} }
impl Debug for FloatNode { impl Debug for FloatNode {
@ -496,6 +505,7 @@ impl Node for FloatNode {
let pos = self.position.get(); let pos = self.position.get();
match seat_data.op_type { match seat_data.op_type {
OpType::Move => { OpType::Move => {
self.restack();
seat_data.dist_hor = seat_data.x; seat_data.dist_hor = seat_data.x;
seat_data.dist_ver = seat_data.y; seat_data.dist_ver = seat_data.y;
} }
@ -579,7 +589,7 @@ impl ContainingNode for FloatNode {
fn cnode_remove_child2(self: Rc<Self>, _child: &dyn Node, _preserve_focus: bool) { fn cnode_remove_child2(self: Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
self.discard_child_properties(); self.discard_child_properties();
self.child.set(None); self.child.set(None);
self.display_link.set(None); self.display_link.borrow_mut().take();
self.workspace_link.set(None); self.workspace_link.set(None);
} }

View file

@ -182,6 +182,9 @@ pub trait ToplevelNodeBase: Node {
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> { fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
None None
} }
fn tl_restack_popups(&self) {
// nothing
}
} }
pub struct FullscreenedData { pub struct FullscreenedData {