1
0
Fork 0
forked from wry/wry

tree: ensure that floats remain accessible after workspace move

This commit is contained in:
Julian Orth 2025-04-24 12:36:18 +02:00
parent 9192446602
commit 3e6640f0ca
2 changed files with 52 additions and 3 deletions

View file

@ -15,7 +15,8 @@ use {
text::TextTexture,
tree::{
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
StackedNode, TileDragDestination, ToplevelNode, WorkspaceNode, walker::NodeVisitor,
OutputNode, StackedNode, TileDragDestination, ToplevelNode, WorkspaceNode,
walker::NodeVisitor,
},
utils::{
asyncevent::AsyncEvent, clonecell::CloneCell, double_click_state::DoubleClickState,
@ -411,6 +412,49 @@ impl FloatNode {
self.stacked_set_visible(ws.float_visible());
}
pub fn adjust_position_after_ws_move(self: &Rc<Self>, output: &Rc<OutputNode>) {
if output.is_dummy {
return;
}
let pos = self.position.get();
let opos = output.global.pos.get();
if pos.intersects(&opos) {
return;
}
let bw = self.state.theme.sizes.border_width.get();
let th = self.state.theme.sizes.title_height.get();
let mut x1 = pos.x1();
let mut x2 = pos.x2();
let mut y1 = pos.y1();
let mut y2 = pos.y2();
const DELTA: i32 = 100;
let delta = bw + DELTA;
macro_rules! adjust {
($z1:ident, $z2:ident) => {
if $z1 > opos.$z2() - delta {
$z1 = (opos.$z2() - delta).max(opos.$z1());
$z2 += $z1 - pos.$z1();
} else if $z2 < opos.$z1() + delta {
$z2 = (opos.$z1() + delta).min(opos.$z2());
$z1 += $z2 - pos.$z2();
}
};
}
adjust!(x1, x2);
adjust!(y1, y2);
if y1 + bw + th <= opos.y1() {
y1 = opos.y1();
y2 += y1 - pos.y1();
}
let new_pos = Rect::new(x1, y1, x2, y2).unwrap();
self.position.set(new_pos);
if self.visible.get() {
self.state.damage(pos);
self.state.damage(new_pos);
}
self.schedule_layout();
}
fn update_child_title(self: &Rc<Self>, title: &str) {
let mut t = self.title.borrow_mut();
if t.deref() != title {

View file

@ -20,8 +20,8 @@ use {
state::State,
text::TextTexture,
tree::{
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
NodeVisitorBase, OutputNode, PlaceholderNode, StackedNode, ToplevelNode,
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FloatNode, FoundNode, Node,
NodeId, NodeVisitorBase, OutputNode, PlaceholderNode, StackedNode, ToplevelNode,
container::ContainerNode, walker::NodeVisitor,
},
utils::{
@ -127,6 +127,11 @@ impl WorkspaceNode {
node.node_visit_children(self);
}
fn visit_float(&mut self, node: &Rc<FloatNode>) {
node.adjust_position_after_ws_move(self.0);
node.node_visit_children(self);
}
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
node.tl_workspace_output_changed();
node.node_visit_children(self);