added view unfocusing

This commit is contained in:
Harrison DiAmbrosio 2025-11-29 22:07:25 -05:00
parent 689b48acd7
commit acb95648e6
2 changed files with 17 additions and 3 deletions

View file

@ -102,6 +102,13 @@ local master = function()
mez.input.add_keymap("alt", "" .. i, {
press = function ()
ctx.tag_id = i
if ctx.tags[i].master then
mez.view.set_focused(ctx.tags[i].master)
else
mez.view.set_focused(nil)
end
tile_all()
end
})

View file

@ -100,11 +100,18 @@ pub fn set_size(L: *zlua.Lua) i32 {
}
// ---Remove focus from current view, and set to given id
// ---@param view_id view_id
// ---@param view_id view_id Id of the view to be focused, or nil to remove focus
pub fn set_focused(L: *zlua.Lua) i32 {
const view_id: u64 = @intCast(L.checkInteger(1));
const view_id: ?c_longlong = L.optInteger(1);
if(server.root.viewById(view_id)) |view| {
if(view_id == null and server.seat.focused_view != null) {
server.seat.focused_view.?.focused = false;
server.seat.focused_view = null;
L.pushNil();
return 1;
}
if(server.root.viewById(@intCast(view_id.?))) |view| {
view.setFocused();
L.pushNil();
return 1;