From 235906cc36d9195b7b36d67f94f40cacccf030fd Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 21 Aug 2026 04:09:57 +0200 Subject: wm: fix usize underflow in move_window at screen edges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ox.saturating_sub(pad) / oy.saturating_sub(pad) — plain subtraction on usize wraps to usize::MAX when the window sits at x=0 or y=0, causing composite_rect to draw at the far end of the framebuffer instead of near the window. Also broke drag-to-move when stuck against the top or left edge. --- rsnix/src/wm.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rsnix/src/wm.rs b/rsnix/src/wm.rs index e5ae6ba..39ad1be 100644 --- a/rsnix/src/wm.rs +++ b/rsnix/src/wm.rs @@ -604,9 +604,10 @@ fn move_window(id: usize, nx: usize, ny: usize) { WINDOWS[id].x = nx; WINDOWS[id].y = ny; } - let pad = 1; - composite_rect(ox - pad, oy - pad, w.w + 2 * pad, w.h + TITLE_BAR_H + 2 * pad); - composite_rect(nx - pad, ny - pad, w.w + 2 * pad, w.h + TITLE_BAR_H + 2 * pad); + let pad: usize = 1; + let oh = w.h + TITLE_BAR_H; + composite_rect(ox.saturating_sub(pad), oy.saturating_sub(pad), w.w + 2 * pad, oh + 2 * pad); + composite_rect(nx.saturating_sub(pad), ny.saturating_sub(pad), w.w + 2 * pad, oh + 2 * pad); } pub fn owner(id: usize) -> Option { -- cgit v1.2.3