summaryrefslogtreecommitdiff
path: root/src/clients/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/mod.rs')
-rw-r--r--src/clients/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index ca9ed91..823a501 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -290,6 +290,30 @@ impl ClientState {
}
}
+ /// Go to the next or previous window in the current monitor, looping around if needed
+ pub fn change_focus(&mut self, conn: &Connection<'_>, increase: bool) {
+ if self.focused.0 >= self.mons.len() {
+ return;
+ }
+
+ let mon = self.focused.0;
+ if self.mons[mon].clients.is_empty() {
+ return;
+ }
+
+ self.refocus(
+ conn,
+ mon,
+ if increase {
+ (self.focused.1 + 1) % self.mons[mon].clients.len()
+ } else if self.focused.1 > 0 {
+ self.focused.1 - 1
+ } else {
+ self.mons[mon].clients.len() - 1
+ },
+ );
+ }
+
/// Get the amount of monitors this state is currently aware of
pub fn monitor_count(&self) -> usize {
self.mons.len()