fix: correctly handle negative coordinates in tui.update_hover

This commit is contained in:
CJ van den Berg 2024-10-13 15:51:28 +02:00
parent f56326be80
commit 1c6a832255
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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 {