diff --git a/runtime/share/mezzaluna/init.lua b/runtime/share/mezzaluna/init.lua index 75dbb1d..aa95fa4 100644 --- a/runtime/share/mezzaluna/init.lua +++ b/runtime/share/mezzaluna/init.lua @@ -51,23 +51,31 @@ mez.input.add_keymap("alt", "v", { end }) +mez.input.add_keymap("alt", "Tab", { + press = function () + print("alt+tab") + + local focused = mez.view.get_focused_id() + local all = mez.view.get_all_ids() + + for _, id in ipairs(all) do + if id ~= focused then + mez.view.set_focused(id) + return + end + end + end +}) + for i = 1, 12 do mez.input.add_keymap("ctrl|alt", "XF86Switch_VT_"..i, { press = function() mez.api.change_vt(i) end }) end --- mez.input.add_keymap("alt", "a", { --- press = function() --- print("hello from my keymap") --- end, --- release = function() --- print("goodbye from my keymap") --- end --- }) - mez.hook.add("ViewMapPre", { callback = function(v) mez.view.set_size(v, 1000, 1000) + mez.view.set_focused(v) end }) diff --git a/src/lua/api.zig b/src/lua/api.zig index 91d0528..be31ed3 100644 --- a/src/lua/api.zig +++ b/src/lua/api.zig @@ -16,6 +16,7 @@ pub fn spawn(L: *zlua.Lua) i32 { } L.checkType(1, .string); + std.log.debug("GOT HERE", .{}); const cmd = L.toString(1) catch { L.raiseErrorStr("Lua error check your config", .{}); diff --git a/src/lua/view.zig b/src/lua/view.zig index 3da0fe2..e759085 100644 --- a/src/lua/view.zig +++ b/src/lua/view.zig @@ -29,7 +29,7 @@ pub fn get_all_ids(L: *zlua.Lua) i32 { pub fn get_focused_id(L: *zlua.Lua) i32 { if(server.seat.focused_view) |view| { - _ = L.pushNumber(@floatFromInt(view.id)); + L.pushInteger(@intCast(view.id)); return 1; } @@ -92,7 +92,7 @@ pub fn set_size(L: *zlua.Lua) i32 { return 0; } -pub fn raise_to_top(L: *zlua.Lua) i32 { +pub fn set_focused(L: *zlua.Lua) i32 { const nargs: i32 = L.getTop(); if(nargs != 1) { @@ -110,7 +110,7 @@ pub fn raise_to_top(L: *zlua.Lua) i32 { return 0; } - view.?.raiseToTop(); + view.?.setFocused(); return 0; } diff --git a/src/view.zig b/src/view.zig index a5fdbc3..a348c96 100644 --- a/src/view.zig +++ b/src/view.zig @@ -95,8 +95,7 @@ pub fn setFocused(self: *View) void { } } - self.raiseToTop(); - + self.scene_tree.node.raiseToTop(); _ = self.xdg_toplevel.setActivated(true); const wlr_keyboard = server.seat.wlr_seat.getKeyboard() orelse return; @@ -113,10 +112,6 @@ pub fn setFocused(self: *View) void { self.focused = true; } -pub fn raiseToTop(self: *View) void { - self.scene_tree.node.raiseToTop(); -} - pub fn setPosition(self: *View, x: i32, y: i32) void { self.scene_tree.node.setPosition(x, y); }