diff options
author | tcmal <me@aria.rip> | 2024-07-04 22:22:46 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-07-04 22:22:46 +0100 |
commit | b9778944ba27e1deeec1be2bdc286790e6274470 (patch) | |
tree | 479e6312692551d1699738ea7da8e3fc44189055 /src/clients/mod.rs | |
parent | d147f26efa31cccf162b939c067ab3b6ed2842e2 (diff) |
support floating windows
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) |