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.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 {