summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 7905735c..0798b51f 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -381,6 +381,24 @@ fn tracksMouse(pane: *const Pane) bool {
/// B2 and B3 are pardes's execute and look, and Shift-B2 and Shift-B3 the
/// program's, reported without the Shift that chose it. True when the
/// event was the program's.
+/// The pointer over the body of a pane whose kind takes the mouse: the
+/// kind's, a press focusing the pane first.
+fn kindMouse(p: *Pardes, m: Mouse) bool {
+ if (p.drag != .none or p.header_drag or p.header_sweep != null) return false;
+ for (p.panes, 0..) |slot, id| {
+ const pane = slot orelse continue;
+ const k = pane.addon orelse continue;
+ if (!k.takesMouse() or pane.collapsed) continue;
+ const r = p.rects[id];
+ const top = p.bodyTop(pane, r) + pane.notices.span();
+ const x0 = r.x + config.GUTTER;
+ if (m.col < x0 or m.col >= r.x + r.w or m.row < top or m.row >= r.y + r.h) continue;
+ if (m.kind == .press) p.active = id;
+ return pardes.Kind.mouse(p, id, m, m.col - x0, m.row - top);
+ }
+ return false;
+}
+
fn programMouse(p: *Pardes, m: Mouse) bool {
const button: ?panes.terminal.MouseButton = switch (m.button) {
.left => .left,
@@ -539,6 +557,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
}
}
p.pointer_inside = true;
+ if (kindMouse(p, m)) return;
if (programMouse(p, m)) return;
emulateButton(p, &m);
if (m.button == .none and m.kind == .motion) {