summaryrefslogtreecommitdiff
path: root/core/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/mouse.zig')
-rw-r--r--core/mouse.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/mouse.zig b/core/mouse.zig
index 5e240930..1882b691 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);
@@ -1497,7 +1500,7 @@ test "mouse thumb buttons navigate once and clear selection gestures" {
}
test "a chorded exec an event reader holds is told with its argument, and written back runs with it" {
- const th = @import("ninep/testing.zig");
+ const th = @import("ninep/harness.zig");
const p = try th.withFile(std.testing.allocator, "Msg said\narg-text\n");
defer p.deinit();
const serial = p.panes[0].?.serial;