summaryrefslogtreecommitdiff
path: root/src/clients/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/mod.rs')
-rw-r--r--src/clients/mod.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 266a61d..8fac307 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -1,5 +1,7 @@
//! Tracking and managing windows.
+use std::cmp::min;
+
use crate::{
config::BORDER_WIDTH,
conn_info::Connection,
@@ -185,14 +187,19 @@ impl ClientState {
// TODO: inserting at index 0 is why dwm uses linked lists, maybe this can be improved
self.mons[mon].clients.insert(0, Client::new(window));
- // TODO: Clamp window size to monitor
+ let MonitorGeometry {
+ width: mon_width,
+ height: mon_height,
+ ..
+ } = self.mons[mon].screen_info;
+
let c = &mut self.mons[mon].clients[0];
c.set_geom(
conn,
geom.x(),
geom.y(),
- geom.width(),
- geom.height(),
+ min(geom.width(), mon_width.saturating_sub(geom.x() as u16)),
+ min(geom.height(), mon_height.saturating_sub(geom.y() as u16)),
BORDER_WIDTH,
);
c.set_border(conn, conn.colours.border_normal());