From 6fd934872a3c9f868bed5bd2f5ee33f0cb748912 Mon Sep 17 00:00:00 2001 From: tcmal Date: Tue, 13 Aug 2024 22:27:16 +0100 Subject: Move to one list of clients, shared across monitors --- src/clients/monitors.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/clients/monitors.rs') diff --git a/src/clients/monitors.rs b/src/clients/monitors.rs index 16348ea..c828fbd 100644 --- a/src/clients/monitors.rs +++ b/src/clients/monitors.rs @@ -5,9 +5,6 @@ use super::{Client, Tag}; /// Info stored for each monitor #[derive(Debug)] pub struct MonitorInfo { - /// Clients attached to that monitor - pub clients: Vec, - /// How clients should be filtered by tag pub focused_tag: TagFocus, @@ -43,19 +40,19 @@ impl TagFocus { } impl MonitorInfo { - /// Iterate over all tiled clients, returning a mutable reference to each. - pub fn clients_tiled_mut(&mut self) -> impl Iterator { - self.clients - .iter_mut() - .filter(|c| c.tiled()) + pub fn iter_visible_tiling<'a>( + &'a self, + i: impl IntoIterator, + ) -> impl Iterator { + i.into_iter() .filter(|c| self.focused_tag.matches(c.tag)) + .filter(|c| c.tiled()) } } impl Default for MonitorInfo { fn default() -> Self { Self { - clients: vec![], screen_info: MonitorGeometry { x_org: 0, y_org: 0, @@ -75,6 +72,13 @@ pub struct MonitorGeometry { pub width: u16, pub height: u16, } +impl MonitorGeometry { + #[allow(clippy::cast_possible_wrap)] + pub(crate) fn contains(self, x: i16, y: i16) -> bool { + (self.x_org..self.x_org + self.width as i16).contains(&x) + && (self.y_org..self.y_org + self.height as i16).contains(&y) + } +} impl From for MonitorGeometry { fn from(value: ScreenInfo) -> Self { -- cgit v1.2.3