Prevent hyperlink hover state when mouse is outside viewport

This commit is contained in:
Bryan Lee
2025-01-21 09:50:15 +08:00
parent 5cb2fa6f75
commit bf6cce23da
3 changed files with 5 additions and 2 deletions

View File

@ -1041,6 +1041,9 @@ fn mouseRefreshLinks(
pos_vp: terminal.point.Coordinate, pos_vp: terminal.point.Coordinate,
over_link: bool, over_link: bool,
) !void { ) !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; self.mouse.link_point = pos_vp;
if (try self.linkAtPos(pos)) |link| { if (try self.linkAtPos(pos)) |link| {

View File

@ -638,7 +638,7 @@ pub const Surface = struct {
.y = @floatCast(opts.scale_factor), .y = @floatCast(opts.scale_factor),
}, },
.size = .{ .width = 800, .height = 600 }, .size = .{ .width = 800, .height = 600 },
.cursor_pos = .{ .x = 0, .y = 0 }, .cursor_pos = .{ .x = -1, .y = -1 },
.keymap_state = .{}, .keymap_state = .{},
}; };

View File

@ -560,7 +560,7 @@ pub fn init(self: *Surface, app: *App, opts: Options) !void {
.font_size = font_size, .font_size = font_size,
.init_config = init_config, .init_config = init_config,
.size = .{ .width = 800, .height = 600 }, .size = .{ .width = 800, .height = 600 },
.cursor_pos = .{ .x = 0, .y = 0 }, .cursor_pos = .{ .x = -1, .y = -1 },
.im_context = im_context, .im_context = im_context,
.cgroup_path = cgroup_path, .cgroup_path = cgroup_path,
}; };