summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/client.rs13
-rw-r--r--src/clients/mod.rs18
-rw-r--r--src/clients/monitors.rs4
3 files changed, 33 insertions, 2 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs
index 394c319..17cfd4f 100644
--- a/src/clients/client.rs
+++ b/src/clients/client.rs
@@ -12,6 +12,7 @@ use super::hints;
/// Information about a single client / window
#[derive(Debug)]
+#[allow(clippy::struct_excessive_bools)]
pub struct Client {
/// The corresponding X11 window
window: Window,
@@ -25,6 +26,7 @@ pub struct Client {
urgent: bool,
never_focus: bool,
+ floating: bool,
}
impl Client {
@@ -39,6 +41,7 @@ impl Client {
mapped: false,
urgent: false,
never_focus: false,
+ floating: false,
}
}
@@ -104,6 +107,16 @@ impl Client {
});
}
+ /// Whether the client is floating - outside of current tiling rules and displaying over any tiled windows
+ pub const fn floating(&self) -> bool {
+ self.floating
+ }
+
+ /// Set the floating status.
+ pub fn set_floating(&mut self, floating: bool) {
+ self.floating = floating;
+ }
+
/// Ensure this client is currently mapped / visible
pub fn ensure_mapped(&mut self, conn: &Connection<'_>) {
if !self.mapped {
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)
diff --git a/src/clients/monitors.rs b/src/clients/monitors.rs
index 0a9bcde..6ca6fdf 100644
--- a/src/clients/monitors.rs
+++ b/src/clients/monitors.rs
@@ -15,8 +15,8 @@ pub struct MonitorInfo {
impl MonitorInfo {
/// Iterate over all tiled clients, returning a mutable reference to each.
pub fn clients_tiled_mut(&mut self) -> impl Iterator<Item = &mut Client> {
- // TODO: tag filtering, floating
- self.clients.iter_mut()
+ // TODO: tag filtering
+ self.clients.iter_mut().filter(|c| !c.floating())
}
}