From e5a36b4d0b8308c0969cd9ff4126113bb7494de2 Mon Sep 17 00:00:00 2001 From: Harrison DiAmbrosio Date: Sun, 7 Dec 2025 11:26:55 -0500 Subject: [PATCH] starting at keyboard exclusivity --- runtime/share/mezzaluna/init.lua | 21 +++++++++++++++------ src/LayerSurface.zig | 9 +++++++++ src/Server.zig | 2 ++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/runtime/share/mezzaluna/init.lua b/runtime/share/mezzaluna/init.lua index 11c8163..42e7097 100644 --- a/runtime/share/mezzaluna/init.lua +++ b/runtime/share/mezzaluna/init.lua @@ -10,11 +10,6 @@ end mez.path.config = mez.fs.joinpath(env_conf, "mez", "init.lua") package.path = package.path..";"..mez.fs.joinpath(env_conf, "mez", "lua", "?.lua") -mez.hook.add("ViewPointerMotion", { - callback = function (view_id, cursor_x, cursor_y) - mez.view.set_focused(view_id) - end -}) local master = function() local config = { @@ -92,6 +87,13 @@ local master = function() }) end + mez.hook.add("ServerStartPost", { + callback = function() + print("ServerStartPost") + print("Doesn't do anything :(") + end + }) + mez.hook.add("ViewMapPre", { callback = function(v) if ctx.tags[ctx.tag_id].master == nil then @@ -135,9 +137,16 @@ local master = function() end }) + mez.hook.add("ViewPointerMotion", { + callback = function (view_id, cursor_x, cursor_y) + mez.view.set_focused(view_id) + end + }) + mez.input.add_keymap("alt", "p", { press = function() - print("no luancher") + -- mez.api.spawn("echo 'the goods' | wmenu") + mez.api.spawn("swaybg -c \"#ff0000\"") end, }) diff --git a/src/LayerSurface.zig b/src/LayerSurface.zig index fb72b47..fd37c9e 100644 --- a/src/LayerSurface.zig +++ b/src/LayerSurface.zig @@ -54,6 +54,15 @@ pub fn init(wlr_layer_surface: *wlr.LayerSurfaceV1) *LayerSurface { return self; } +pub fn allowKeyboard(self: *LayerSurface) void { + if(self.wlr_layer_surface.output == null or self.wlr_layer_surface.output.?.data == null) { + std.log.err("Layer surface does not have an associated output"); + } + + const output: *Output = @ptrCast(@alignCast(self.wlr_layer_surface.output.?.data.?)); + output.setFocused(); +} + pub fn deinit(self: *LayerSurface) void { self.destroy.link.remove(); self.map.link.remove(); diff --git a/src/Server.zig b/src/Server.zig index d6c61b0..80d72ad 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -128,6 +128,8 @@ pub fn init(self: *Server) void { // LayerShell events self.layer_shell.events.new_surface.add(&self.new_layer_surface); + + self.events.exec("ServerStartPost", .{}); } pub fn deinit(self: *Server) noreturn {