From b9778944ba27e1deeec1be2bdc286790e6274470 Mon Sep 17 00:00:00 2001 From: tcmal Date: Thu, 4 Jul 2024 22:22:46 +0100 Subject: support floating windows --- src/clients/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/clients/mod.rs') 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) -- cgit v1.2.3