From c3f78bc69dc9f8ae84441441b4838e511c6328b1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 28 Jun 2024 23:45:42 -0500 Subject: [PATCH] core: mouse within top/bottom 1 pixel should scroll selection Fixes #1892 We previously required a negative y or y beyond the height of the window but in a full screen scenario neither happen, so we add a one pixel buffer instead where we still scroll. --- src/Surface.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Surface.zig b/src/Surface.zig index 25fa09713..2227e1f37 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2567,10 +2567,12 @@ pub fn cursorPosCallback( // If our y is negative, we're above the window. In this case, we scroll // up. The amount we scroll up is dependent on how negative we are. + // We allow for a 1 pixel buffer at the top and bottom to detect + // scroll even in full screen windows. // Note: one day, we can change this from distance to time based if we want. //log.warn("CURSOR POS: {} {}", .{ pos, self.screen_size }); const max_y: f32 = @floatFromInt(self.screen_size.height); - if (pos.y < 0 or pos.y > max_y) { + if (pos.y <= 1 or pos.y > max_y - 1) { const delta: isize = if (pos.y < 0) -1 else 1; try self.io.terminal.scrollViewport(.{ .delta = delta });