diff options
Diffstat (limited to 'src/clients/mod.rs')
-rw-r--r-- | src/clients/mod.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs index fe0a4d3..445c24c 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -322,6 +322,14 @@ impl ClientState { ); } + /// Toggle whether the client with the given position is floating + pub fn toggle_floating(&mut self, conn: &Connection<'_>, (mon, pos): (usize, usize)) { + let c = &mut self.mons[mon].clients[pos]; + c.set_floating(!c.floating()); + + self.rearrange_monitor(conn, mon); + } + /// Get the amount of monitors this state is currently aware of pub fn monitor_count(&self) -> usize { self.mons.len() @@ -371,6 +379,16 @@ impl ClientState { self.client(self.focused.0, self.focused.1) } + /// Get the position of the currently focused client, if it exists + pub fn focused_pos(&self) -> Option<(usize, usize)> { + let (mon, pos) = self.focused; + if mon < self.mons.len() && pos < self.mons[mon].clients.len() { + Some((mon, pos)) + } else { + None + } + } + /// Get a mutable reference to the currently focused client, if it exists. pub fn focused_mut(&mut self) -> Option<&mut Client> { self.client_mut(self.focused.0, self.focused.1) |