From d2506fbbee01e26f8decd0ce2371e674086c4300 Mon Sep 17 00:00:00 2001 From: tcmal Date: Fri, 30 Aug 2024 14:35:31 +0100 Subject: Switch workspace as needed when refocusing --- src/clients/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/clients/mod.rs b/src/clients/mod.rs index dcce37a..6481c0f 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -124,6 +124,7 @@ impl WM<'_> { // The above may fail if the window has already been destroyed - just discard the error here. let _ = self.conn.check_request(cookie); } + if self .clients .focused() @@ -233,9 +234,17 @@ impl ClientState { /// If the given index is invalid, focus on the root instead. pub fn refocus(&mut self, conn: &Connection<'_>, i: ClientIdx) { self.unfocus(conn); - if let Some(new) = self.set_focused(i) { + if self.set_focused(i).is_some() { + let mon_idx = self.client_mon_idx(i); + let tag = self.client(i).tag; + if !self.mons[mon_idx].focused_tag.matches(tag) { + self.set_mon_tag_focus(conn, mon_idx, TagFocus::Tag(tag)); + } + + let new = self.client_mut(i); new.set_border(conn, conn.colours.border_focused()); new.sync_hints(conn, true); + buttons::grab(conn, new.window(), true); if !new.never_focus() { conn.send_request(&SetInputFocus { @@ -252,7 +261,6 @@ impl ClientState { }); conn.send_event(new.window(), conn.atoms.wm_take_focus); } - // TODO: Update focused tag } else { conn.send_request(&SetInputFocus { revert_to: InputFocus::PointerRoot, @@ -475,7 +483,6 @@ impl ClientState { self.focused_client.map(|i| self.client_mut(i)) } - /// Get the position of the currently focused client. This position may be invalid. pub fn is_focused(&self, e: Window) -> bool { self.focused().is_some_and(|c| c.window() == e) } -- cgit v1.2.3