mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-13 23:36:09 +03:00
Prevent hyperlink hover state when mouse is outside viewport (#5267)
## Description Fixed an issue where hyperlinks would maintain their hover state when the mouse is outside the viewport while holding the Cmd key. This created inconsistent behavior with the window's standard hover state clearing logic. ## Changes - Added viewport boundary check in `mouseRefreshLinks` function to prevent link processing when cursor is outside the window ## Testing To reproduce and verify the fix: 1. Run `fd --hyperlink "\.zig$" src/apprt` to create hyperlinks 2. Move mouse over a hyperlink (it should highlight) 3. Move mouse outside window 4. Hold Cmd key - Before: Link would show hover state - After: Link remains in non-hover state Fixes #5252 @rrotter Could you please try this to see if it solves your issue?
This commit is contained in:
@ -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| {
|
||||
|
@ -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 = .{},
|
||||
};
|
||||
|
||||
|
@ -559,7 +559,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,
|
||||
};
|
||||
|
Reference in New Issue
Block a user