From 1c6a832255d205e50fb1cd4ab8cd1f358e361681 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 13 Oct 2024 15:51:28 +0200 Subject: [PATCH] fix: correctly handle negative coordinates in tui.update_hover --- src/tui/tui.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tui/tui.zig b/src/tui/tui.zig index e5d1aa9..48da4f8 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -509,7 +509,7 @@ fn send_mouse_drag(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.mess fn update_hover(self: *Self, y: c_int, x: c_int) !?*Widget { self.last_hover_y = y; self.last_hover_x = x; - if (self.find_coord_widget(@intCast(y), @intCast(x))) |w| { + if (y > 0 and x > 0) if (self.find_coord_widget(@intCast(y), @intCast(x))) |w| { if (if (self.hover_focus) |h| h != w else true) { var buf: [256]u8 = undefined; if (self.hover_focus) |h| { @@ -520,10 +520,9 @@ fn update_hover(self: *Self, y: c_int, x: c_int) !?*Widget { _ = try w.send(tp.self_pid(), tp.message.fmtbuf(&buf, .{ "H", true }) catch |e| return tp.exit_error(e, @errorReturnTrace())); } return w; - } else { - try self.clear_hover_focus(); - return null; - } + }; + try self.clear_hover_focus(); + return null; } fn clear_hover_focus(self: *Self) tp.result {