From 8fc827a3b30de16b6adbf80abea3bc224d507268 Mon Sep 17 00:00:00 2001 From: tcmal Date: Fri, 30 Aug 2024 16:51:50 +0100 Subject: Add bind for going back and forth between tags --- src/clients/mod.rs | 6 ++++++ src/clients/monitors.rs | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'src/clients') diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 70ffb00..d093fb1 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -432,11 +432,17 @@ impl ClientState { .for_each(|c| c.ensure_unmapped(conn)); debug!("setting tag focus to {:?} on mon {}", tag_focus, mon); + self.mons[mon].last_focused_tag = curr_focus; self.mons[mon].focused_tag = tag_focus; self.unfocus(conn); self.rearrange_mon(conn, mon); } + /// Set the given monitor's focused tag to its previous value + pub fn mon_prev_tag_focus(&mut self, conn: &Connection<'_>, mon: MonitorIdx) { + self.set_mon_tag_focus(conn, mon, self.mons[mon].last_focused_tag); + } + /// Set the tag for the given client pub fn set_client_tag(&mut self, conn: &Connection<'_>, pos: ClientIdx, tag: Tag) { let c = self.client_mut(pos); diff --git a/src/clients/monitors.rs b/src/clients/monitors.rs index c828fbd..ba59772 100644 --- a/src/clients/monitors.rs +++ b/src/clients/monitors.rs @@ -8,6 +8,9 @@ pub struct MonitorInfo { /// How clients should be filtered by tag pub focused_tag: TagFocus, + /// The previously focused tag, for going back-and-forth + pub last_focused_tag: TagFocus, + /// The monitor's geometry pub screen_info: MonitorGeometry, } @@ -60,6 +63,7 @@ impl Default for MonitorInfo { height: 0, }, focused_tag: TagFocus::Tag(1), + last_focused_tag: TagFocus::Tag(1), } } } -- cgit v1.2.3