summaryrefslogtreecommitdiff
path: root/core/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/mouse.zig')
-rw-r--r--core/mouse.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/mouse.zig b/core/mouse.zig
index 3d7c5af9..8d0aebc8 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -247,8 +247,11 @@ fn kindMouse(p: *Pardes, m: Mouse) bool {
if (m.kind == .press) v.active = id;
if (m.kind == .press and m.button != .wheel_up and m.button != .wheel_down and m.button != .wheel_left and m.button != .wheel_right) v.kind_grab = @intCast(id);
if (m.kind == .release) v.kind_grab = null;
- const col = std.math.clamp(m.col, x0, r.x + r.w -| 1) - x0;
- const row = std.math.clamp(m.row, top, r.y + r.h -| 1) - top;
+ // Grabbed, it may be anywhere, and the pane since made too narrow
+ // or short for a cell of body (a resize, a pane added above): its
+ // body's last cell, the first of none.
+ const col = @min(m.col -| x0, (r.x + r.w) -| x0 -| 1);
+ const row = @min(m.row -| top, (r.y + r.h) -| top -| 1);
return pardes.Kind.mouse(p, id, m, col, row);
}
kindLeave(p);