1
0
Fork 0
forked from wry/wry

tree: allow focusing workspace nodes

This commit is contained in:
khyperia 2025-12-24 15:53:31 +01:00 committed by Julian Orth
parent dd3f8bad40
commit 5bb19f3ca7
12 changed files with 76 additions and 22 deletions

View file

@ -96,6 +96,7 @@ pub struct OutputNode {
pub bar_rect: Cell<Rect>,
pub bar_rect_rel: Cell<Rect>,
pub bar_rect_with_separator: Cell<Rect>,
pub bar_separator_rect: Cell<Rect>,
pub bar_separator_rect_rel: Cell<Rect>,
pub render_data: RefCell<OutputRenderData>,
pub state: Rc<State>,
@ -774,11 +775,11 @@ impl OutputNode {
let mut bar_rect = Rect::default();
let mut bar_rect_rel = Rect::default();
let mut bar_rect_with_separator = Rect::default();
let mut bar_separator_rect = Rect::default();
let mut bar_separator_rect_rel = Rect::default();
let mut workspace_rect = non_exclusive_rect;
let mut workspace_rect_rel = non_exclusive_rect_rel;
if self.state.show_bar.get() {
let bar_separator_rect;
match self.state.theme.bar_position.get() {
BarPosition::Bottom => {
workspace_rect = Rect::new_sized_saturating(x1, y1, width, height - bh - bsw);
@ -805,6 +806,7 @@ impl OutputNode {
self.bar_rect.set(bar_rect);
self.bar_rect_rel.set(bar_rect_rel);
self.bar_rect_with_separator.set(bar_rect_with_separator);
self.bar_separator_rect.set(bar_separator_rect);
self.bar_separator_rect_rel.set(bar_separator_rect_rel);
self.workspace_rect.set(workspace_rect);
self.workspace_rect_rel.set(workspace_rect_rel);
@ -1147,20 +1149,13 @@ impl OutputNode {
set_layer_visible!(self.layers[3], visible);
}
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, id: PointerType) {
fn bar_button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: i32, y: i32) -> bool {
if !self.state.show_bar.get() {
return;
}
let (x, y) = match self.pointer_positions.get(&id) {
Some(p) => p,
_ => return,
};
if let PointerType::Seat(s) = id {
self.pointer_down.set(s, (x, y));
return false;
}
let bar_rect_rel = self.bar_rect_rel.get();
if bar_rect_rel.not_contains(x, y) {
return;
return false;
}
let (x, _) = bar_rect_rel.translate(x, y);
let ws = 'ws: {
@ -1170,9 +1165,25 @@ impl OutputNode {
break 'ws title.ws.clone();
}
}
return;
return true;
};
self.state.show_workspace2(Some(seat), &self, &ws);
self.state.show_workspace2(Some(seat), self, &ws);
true
}
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, id: PointerType) {
let (x, y) = match self.pointer_positions.get(&id) {
Some(p) => p,
_ => return,
};
if let PointerType::Seat(s) = id {
self.pointer_down.set(s, (x, y));
}
if self.bar_button(seat, x, y) {
return;
}
let ws = self.ensure_workspace();
seat.focus_node(ws);
}
pub fn update_presentation_type(&self) {
@ -1489,6 +1500,10 @@ impl OutputNode {
if c.node_visible() {
c.node_do_focus(seat, direction);
}
} else {
if ws.node_visible() {
seat.focus_node(ws);
}
}
}
}

View file

@ -366,17 +366,23 @@ impl Node for WorkspaceNode {
seat.focus_node(last);
} else if let Some(container) = self.container.get() {
container.node_do_focus(seat, direction);
} else if let Some(float) = self
} else if let Some(child) = self
.stacked
.rev_iter()
.find_map(|node| (*node).clone().node_into_float())
.filter_map(|node| (*node).clone().node_into_float())
.find_map(|float| float.child.get())
{
if let Some(child) = float.child.get() {
child.node_do_focus(seat, direction);
}
child.node_do_focus(seat, direction);
} else {
seat.focus_node(self);
}
}
fn node_active_changed(&self, _active: bool) {
let output = self.output.get();
self.state.damage(output.bar_separator_rect.get());
}
fn node_find_tree_at(
&self,
x: i32,