diff options
-rw-r--r-- | src/clients/mod.rs | 13 | ||||
-rw-r--r-- | todos.org | 2 |
2 files changed, 10 insertions, 5 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()); @@ -1,5 +1,3 @@ -* Clamp window size to monitor - * Send xmoveresizewindow event * Inherit monitor from parent if window is transient |