diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clients/mod.rs | 6 | ||||
-rw-r--r-- | src/clients/monitors.rs | 4 | ||||
-rw-r--r-- | src/config.rs | 5 | ||||
-rw-r--r-- | src/helpers.rs | 6 |
4 files changed, 19 insertions, 2 deletions
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), } } } diff --git a/src/config.rs b/src/config.rs index 723f0e7..2b5e34d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,8 +9,8 @@ use crate::{ clients::TagFocus, conn_info::Colour, helpers::{ - focus_next, focus_prev, kill_client, mouse_move, mouse_resize, set_tag, set_tag_focus, - shift_down, shift_top, shift_up, spawn, toggle_floating, toggle_fullscreen, + focus_next, focus_prev, kill_client, mouse_move, mouse_resize, prev_tag_focus, set_tag, + set_tag_focus, shift_down, shift_top, shift_up, spawn, toggle_floating, toggle_fullscreen, }, keys::Keybinds, }; @@ -53,6 +53,7 @@ pub const KEYBINDS: Keybinds = Keybinds(&[ bind!(MAIN_MODIFIER.union(ModMask::SHIFT) , space -> &toggle_floating), bind!(MAIN_MODIFIER.union(ModMask::SHIFT) , f -> &toggle_fullscreen), bind!(MAIN_MODIFIER.union(ModMask::SHIFT) , q -> &kill_client), + bind!(MAIN_MODIFIER , Tab -> &prev_tag_focus), bind!(MAIN_MODIFIER , _1 -> &|wm| set_tag_focus(wm, TagFocus::Tag(1))), bind!(MAIN_MODIFIER , _2 -> &|wm| set_tag_focus(wm, TagFocus::Tag(2))), bind!(MAIN_MODIFIER , _3 -> &|wm| set_tag_focus(wm, TagFocus::Tag(3))), diff --git a/src/helpers.rs b/src/helpers.rs index cd9fd18..d882bbe 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -98,6 +98,12 @@ pub fn set_tag_focus(wm: &mut WM<'_>, tag_focus: TagFocus) { .set_mon_tag_focus(&wm.conn, wm.clients.focused_mon_idx(), tag_focus); } +/// Set the focused tag for the currently selected monitor to the previous value +pub fn prev_tag_focus(wm: &mut WM<'_>) { + wm.clients + .mon_prev_tag_focus(&wm.conn, wm.clients.focused_mon_idx()); +} + /// Set the tag for the currently selected client pub fn set_tag(wm: &mut WM<'_>, tag: Tag) { if let Some(pos) = wm.clients.focused_pos() { |