fix: set home screen focus on mouse events

This commit is contained in:
CJ van den Berg 2026-01-15 12:17:31 +01:00
parent cb1797d98c
commit 4a545beb99
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3,6 +3,7 @@ const build_options = @import("build_options");
const tp = @import("thespian"); const tp = @import("thespian");
const log = @import("log"); const log = @import("log");
const cbor = @import("cbor"); const cbor = @import("cbor");
const input = @import("input");
const builtin = @import("builtin"); const builtin = @import("builtin");
const Plane = @import("renderer").Plane; const Plane = @import("renderer").Plane;
@ -208,6 +209,13 @@ pub fn receive(_: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
tui.need_render(); tui.need_render();
return true; return true;
} }
if (try m.match(.{ "B", input.event.press, @intFromEnum(input.mouse.BUTTON1), tp.more }) or
try m.match(.{ "B", input.event.press, @intFromEnum(input.mouse.BUTTON2), tp.more }) or
try m.match(.{ "B", input.event.press, @intFromEnum(input.mouse.BUTTON3), tp.more }))
return switch (tui.set_focus_by_mouse_event()) {
.changed, .same => true,
.notfound => false,
};
return false; return false;
} }
@ -281,6 +289,7 @@ fn menu_on_render(self: *Self, button: *ButtonType, theme: *const Widget.Theme,
} }
fn menu_action(_: **Menu.State(*Self), button: *ButtonType, _: Widget.Pos) void { fn menu_action(_: **Menu.State(*Self), button: *ButtonType, _: Widget.Pos) void {
_ = tui.set_focus_by_mouse_event();
var description: []const u8 = undefined; var description: []const u8 = undefined;
var hint: []const u8 = undefined; var hint: []const u8 = undefined;
var command_name: []const u8 = undefined; var command_name: []const u8 = undefined;