summaryrefslogtreecommitdiff
path: root/src/clients/monitors.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-13 22:27:16 +0100
committertcmal <me@aria.rip>2024-08-14 17:45:21 +0100
commit6fd934872a3c9f868bed5bd2f5ee33f0cb748912 (patch)
tree13f844d164ac7ffe44484ad24bed50ef6393b776 /src/clients/monitors.rs
parentf9d5af7f060ada6f224861967e31bb74a0d24e18 (diff)
Move to one list of clients, shared across monitors
Diffstat (limited to 'src/clients/monitors.rs')
-rw-r--r--src/clients/monitors.rs22
1 files changed, 13 insertions, 9 deletions
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<Client>,
-
/// 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<Item = &mut Client> {
- self.clients
- .iter_mut()
- .filter(|c| c.tiled())
+ pub fn iter_visible_tiling<'a>(
+ &'a self,
+ i: impl IntoIterator<Item = &'a mut Client>,
+ ) -> impl Iterator<Item = &'a mut Client> {
+ 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<ScreenInfo> for MonitorGeometry {
fn from(value: ScreenInfo) -> Self {