summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-07-04 21:46:08 +0100
committertcmal <me@aria.rip>2024-07-04 21:46:08 +0100
commit19d4dac4d9b30fdebc445c70e6524c0d207b6917 (patch)
tree5a243908ab0f4f114ae1e56f6060dcaa1caff323 /src/clients
parent1930c53309e0b66ec2100a6e85b2714b2153d438 (diff)
clamp window size to monitor
Diffstat (limited to 'src/clients')
-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());