summaryrefslogtreecommitdiff
path: root/src/clients/monitors.rs
diff options
context:
space:
mode:
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),
}
}
}