fix: don't send hover events to dead widgets

This commit is contained in:
CJ van den Berg 2024-08-13 22:57:21 +02:00
parent f53dc74e9d
commit 26ef53747d

View file

@ -493,6 +493,7 @@ fn send_mouse(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message)
} else { } else {
if (self.hover_focus) |h| { if (self.hover_focus) |h| {
var buf: [256]u8 = undefined; var buf: [256]u8 = undefined;
if (self.is_live_widget_ptr(h))
_ = try h.send(tp.self_pid(), tp.message.fmtbuf(&buf, .{ "H", false }) catch |e| return tp.exit_error(e, @errorReturnTrace())); _ = try h.send(tp.self_pid(), tp.message.fmtbuf(&buf, .{ "H", false }) catch |e| return tp.exit_error(e, @errorReturnTrace()));
} }
self.hover_focus = null; self.hover_focus = null;
@ -524,6 +525,7 @@ fn send_mouse_drag(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.mess
fn clear_hover_focus(self: *Self) tp.result { fn clear_hover_focus(self: *Self) tp.result {
if (self.hover_focus) |h| { if (self.hover_focus) |h| {
var buf: [256]u8 = undefined; var buf: [256]u8 = undefined;
if (self.is_live_widget_ptr(h))
_ = try h.send(tp.self_pid(), tp.message.fmtbuf(&buf, .{ "H", false }) catch |e| return tp.exit_error(e, @errorReturnTrace())); _ = try h.send(tp.self_pid(), tp.message.fmtbuf(&buf, .{ "H", false }) catch |e| return tp.exit_error(e, @errorReturnTrace()));
} }
self.hover_focus = null; self.hover_focus = null;