From e85accf8052d333178b7e64994d674598f36e8ee Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 18 Jul 2025 21:00:52 +0200 Subject: [PATCH] workspace: use State::show_workspace2 to make workspaces visible --- .../ext_workspace_manager_v1.rs | 8 +++---- src/state.rs | 20 ++++++++++-------- src/tree/output.rs | 21 +++++-------------- src/tree/workspace.rs | 7 +++---- 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/ifs/workspace_manager/ext_workspace_manager_v1.rs b/src/ifs/workspace_manager/ext_workspace_manager_v1.rs index 0893353e..c050f582 100644 --- a/src/ifs/workspace_manager/ext_workspace_manager_v1.rs +++ b/src/ifs/workspace_manager/ext_workspace_manager_v1.rs @@ -250,10 +250,10 @@ impl ExtWorkspaceManagerV1RequestHandler for ExtWorkspaceManagerV1 { continue; }; let output = ws.output.get(); - output.show_workspace(&ws); - ws.flush_jay_workspaces(); - output.schedule_update_render_data(); - self.client.state.tree_changed(); + let seat = self.client.state.seat_queue.last().as_deref().cloned(); + self.client + .state + .show_workspace2(seat.as_ref(), &output, &ws); } WorkspaceChange::AssignWorkspace(w, o) => { let Some(ws) = w.get() else { diff --git a/src/state.rs b/src/state.rs index 08356aec..28fa3f35 100644 --- a/src/state.rs +++ b/src/state.rs @@ -853,8 +853,12 @@ impl State { node.node_do_focus(&seat, Direction::Unspecified); } - pub fn show_workspace2(&self, seat: Option<&Rc>, ws: &Rc) { - let output = ws.output.get(); + pub fn show_workspace2( + &self, + seat: Option<&Rc>, + output: &Rc, + ws: &Rc, + ) { let mut pinned_is_focused = false; if let Some(seat) = seat { for pinned in output.pinned.iter() { @@ -876,12 +880,10 @@ impl State { return; } ws.flush_jay_workspaces(); - output.schedule_update_render_data(); - self.tree_changed(); - // let seats = self.globals.seats.lock(); - // for seat in seats.values() { - // seat.workspace_changed(&output); - // } + if !output.is_dummy { + output.schedule_update_render_data(); + self.tree_changed(); + } } pub fn show_workspace(&self, seat: &Rc, name: &str) { @@ -896,7 +898,7 @@ impl State { output.create_workspace(name) } }; - self.show_workspace2(Some(seat), &ws); + self.show_workspace2(Some(seat), &ws.output.get(), &ws); } pub fn float_map_ws(&self) -> Rc { diff --git a/src/tree/output.rs b/src/tree/output.rs index 8588fb56..f5db42c1 100644 --- a/src/tree/output.rs +++ b/src/tree/output.rs @@ -1081,7 +1081,7 @@ impl OutputNode { set_layer_visible!(self.layers[3], visible); } - fn button(self: Rc, id: PointerType) { + fn button(self: Rc, seat: &Rc, id: PointerType) { if !self.state.show_bar.get() { return; } @@ -1105,10 +1105,7 @@ impl OutputNode { } return; }; - self.show_workspace(&ws); - ws.flush_jay_workspaces(); - self.schedule_update_render_data(); - self.state.tree_changed(); + self.state.show_workspace2(Some(seat), &self, &ws); } pub fn update_presentation_type(&self) { @@ -1628,7 +1625,7 @@ impl Node for OutputNode { self.pointer_down.remove(&seat.id()); return; } - self.button(PointerType::Seat(seat.id())); + self.button(seat, PointerType::Seat(seat.id())); } fn node_on_axis_event(self: Rc, seat: &Rc, event: &PendingScroll) { @@ -1658,15 +1655,7 @@ impl Node for OutputNode { None => break, }; } - if !self.show_workspace(&ws) { - return; - } - ws.flush_jay_workspaces(); - ws.deref() - .clone() - .node_do_focus(seat, Direction::Unspecified); - self.schedule_update_render_data(); - self.state.tree_changed(); + self.state.show_workspace2(Some(seat), &self, &ws); } fn node_on_leave(&self, seat: &WlSeatGlobal) { @@ -1730,7 +1719,7 @@ impl Node for OutputNode { self.pointer_move(id, x, y); if let Some(changes) = changes { if changes.down == Some(true) { - self.button(id); + self.button(tool.seat(), id); } } } diff --git a/src/tree/workspace.rs b/src/tree/workspace.rs index 8e265450..8b118bef 100644 --- a/src/tree/workspace.rs +++ b/src/tree/workspace.rs @@ -367,7 +367,7 @@ impl Node for WorkspaceNode { if self.is_dummy { return; } - self.state.show_workspace2(None, &self); + self.state.show_workspace2(None, &self.output.get(), &self); } fn node_on_pointer_focus(&self, seat: &Rc) { @@ -499,14 +499,13 @@ pub fn move_ws_to_output( && (config.make_visible_always || (config.make_visible_if_empty && target.workspace.is_none())); if make_visible { - target.show_workspace(&ws); + ws.state.show_workspace2(None, target, &ws); } else { ws.set_visible(false); } ws.flush_jay_workspaces(); if let Some(ws) = new_source_ws { - source.show_workspace(&ws); - ws.flush_jay_workspaces(); + ws.state.show_workspace2(None, &source, &ws); } if !target.is_dummy { target.schedule_update_render_data();