summaryrefslogtreecommitdiff
path: root/src/clients/monitors.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-06 14:39:55 +0100
committertcmal <me@aria.rip>2024-08-13 17:07:19 +0100
commit89b5f3f87c8022f2d32c422c3516fca2f1538d69 (patch)
tree231457b673cafbfdaea32a8f6a9d8c0aba08a7d3 /src/clients/monitors.rs
parent5359062bf58a5ff57dfa48492db57f9340ecfbee (diff)
Add tags/workspaces
Diffstat (limited to 'src/clients/monitors.rs')
-rw-r--r--src/clients/monitors.rs39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/clients/monitors.rs b/src/clients/monitors.rs
index 6790632..16348ea 100644
--- a/src/clients/monitors.rs
+++ b/src/clients/monitors.rs
@@ -1,6 +1,6 @@
use xcb::xinerama::ScreenInfo;
-use super::Client;
+use super::{Client, Tag};
/// Info stored for each monitor
#[derive(Debug)]
@@ -8,15 +8,47 @@ pub struct MonitorInfo {
/// Clients attached to that monitor
pub clients: Vec<Client>,
+ /// How clients should be filtered by tag
+ pub focused_tag: TagFocus,
+
/// The monitor's geometry
pub screen_info: MonitorGeometry,
}
+/// How clients are currently being filtered by tag
+#[derive(Debug, Clone, Copy)]
+pub enum TagFocus {
+ /// Only show clients with the given tag
+ Tag(Tag),
+
+ /// Show all clients
+ All,
+}
+impl TagFocus {
+ /// Check if a client with the given tag should be displayed when using this filter
+ pub const fn matches(&self, tag: Tag) -> bool {
+ match self {
+ Self::Tag(x) => *x == tag,
+ Self::All => true,
+ }
+ }
+
+ /// Get the tag that new clients should be assigned when using this filter
+ pub const fn create_tag(&self) -> Tag {
+ match self {
+ Self::Tag(x) => *x,
+ Self::All => 1,
+ }
+ }
+}
+
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
- self.clients.iter_mut().filter(|c| c.tiled())
+ self.clients
+ .iter_mut()
+ .filter(|c| c.tiled())
+ .filter(|c| self.focused_tag.matches(c.tag))
}
}
@@ -30,6 +62,7 @@ impl Default for MonitorInfo {
width: 0,
height: 0,
},
+ focused_tag: TagFocus::Tag(1),
}
}
}