From bf6cce23da165c80622f7b12fefd3193d02c2d96 Mon Sep 17 00:00:00 2001 From: Bryan Lee <38807139+liby@users.noreply.github.com> Date: Tue, 21 Jan 2025 09:50:15 +0800 Subject: [PATCH] Prevent hyperlink hover state when mouse is outside viewport --- src/Surface.zig | 3 +++ src/apprt/embedded.zig | 2 +- src/apprt/gtk/Surface.zig | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 138aa2ea2..d9a985aa7 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -1041,6 +1041,9 @@ fn mouseRefreshLinks( pos_vp: terminal.point.Coordinate, over_link: bool, ) !void { + // If the position is outside our viewport, do nothing + if (pos.x < 0 or pos.y < 0) return; + self.mouse.link_point = pos_vp; if (try self.linkAtPos(pos)) |link| { diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 44c4c5f20..013117f15 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -638,7 +638,7 @@ pub const Surface = struct { .y = @floatCast(opts.scale_factor), }, .size = .{ .width = 800, .height = 600 }, - .cursor_pos = .{ .x = 0, .y = 0 }, + .cursor_pos = .{ .x = -1, .y = -1 }, .keymap_state = .{}, }; diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 61866dcec..21d811623 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -560,7 +560,7 @@ pub fn init(self: *Surface, app: *App, opts: Options) !void { .font_size = font_size, .init_config = init_config, .size = .{ .width = 800, .height = 600 }, - .cursor_pos = .{ .x = 0, .y = 0 }, + .cursor_pos = .{ .x = -1, .y = -1 }, .im_context = im_context, .cgroup_path = cgroup_path, };