summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-06-26 21:52:09 +0100
committertcmal <me@aria.rip>2024-06-26 21:52:09 +0100
commitadcf670ba60c4489b14d4b9dd03a0f7799cf8fb7 (patch)
treef99dbd4a0d3504278ed16f7cd5753f2a5402675c /src/clients
parent6785d154460921cc3b774376a676a226402d8270 (diff)
start adding some more keybinds
Diffstat (limited to 'src/clients')
-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()