summaryrefslogtreecommitdiff
path: root/src/clients/monitors.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-06-21 19:13:12 +0100
committertcmal <me@aria.rip>2024-06-21 19:13:12 +0100
commit475253b7bcfd03a932c4b7efd969b3d2bf155035 (patch)
tree44789ce271d14c89cbff777e75f1e9ab6e1a5e64 /src/clients/monitors.rs
parentc3e98e34ed7d42ef4271339de88f7131e7647442 (diff)
refactor connection-related stuff out, make things a bit cleaner
Diffstat (limited to 'src/clients/monitors.rs')
-rw-r--r--src/clients/monitors.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/clients/monitors.rs b/src/clients/monitors.rs
new file mode 100644
index 0000000..0a9bcde
--- /dev/null
+++ b/src/clients/monitors.rs
@@ -0,0 +1,55 @@
+use xcb::xinerama::ScreenInfo;
+
+use super::Client;
+
+/// Info stored for each monitor
+#[derive(Debug)]
+pub struct MonitorInfo {
+ /// Clients attached to that monitor
+ pub clients: Vec<Client>,
+
+ /// The monitor's geometry
+ pub screen_info: MonitorGeometry,
+}
+
+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, floating
+ self.clients.iter_mut()
+ }
+}
+
+impl Default for MonitorInfo {
+ fn default() -> Self {
+ Self {
+ clients: vec![],
+ screen_info: MonitorGeometry {
+ x_org: 0,
+ y_org: 0,
+ width: 0,
+ height: 0,
+ },
+ }
+ }
+}
+
+/// Info on the monitor's geometry.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct MonitorGeometry {
+ pub x_org: i16,
+ pub y_org: i16,
+ pub width: u16,
+ pub height: u16,
+}
+
+impl From<ScreenInfo> for MonitorGeometry {
+ fn from(value: ScreenInfo) -> Self {
+ Self {
+ x_org: value.x_org,
+ y_org: value.y_org,
+ width: value.width,
+ height: value.height,
+ }
+ }
+}