mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
reformatted with zig fmt
This commit is contained in:
parent
e6a45f91b6
commit
6be66b6a71
32 changed files with 2108 additions and 2237 deletions
|
|
@ -14,31 +14,31 @@ const Lua = &@import("../main.zig").lua;
|
|||
modifier: wlr.Keyboard.ModifierMask,
|
||||
keycode: xkb.Keysym,
|
||||
options: struct {
|
||||
repeat: bool,
|
||||
/// This is the location of the on press lua function in the lua registry
|
||||
lua_press_ref_idx: i32,
|
||||
/// This is the location of the on release lua function in the lua registry
|
||||
lua_release_ref_idx: i32,
|
||||
repeat: bool,
|
||||
/// This is the location of the on press lua function in the lua registry
|
||||
lua_press_ref_idx: i32,
|
||||
/// This is the location of the on release lua function in the lua registry
|
||||
lua_release_ref_idx: i32,
|
||||
},
|
||||
|
||||
pub fn callback(self: *const Keymap, release: bool) void {
|
||||
const lua_ref_idx = if (release) self.options.lua_release_ref_idx else self.options.lua_press_ref_idx;
|
||||
const lua_ref_idx = if (release) self.options.lua_release_ref_idx else self.options.lua_press_ref_idx;
|
||||
|
||||
const t = Lua.state.rawGetIndex(zlua.registry_index, lua_ref_idx);
|
||||
if (t != zlua.LuaType.function) {
|
||||
RemoteLua.sendNewLogEntry("Failed to call keybind, it doesn't have a callback.");
|
||||
Lua.state.pop(1);
|
||||
return;
|
||||
}
|
||||
const t = Lua.state.rawGetIndex(zlua.registry_index, lua_ref_idx);
|
||||
if (t != zlua.LuaType.function) {
|
||||
RemoteLua.sendNewLogEntry("Failed to call keybind, it doesn't have a callback.");
|
||||
Lua.state.pop(1);
|
||||
return;
|
||||
}
|
||||
|
||||
Lua.state.protectedCall(.{ .args = 0, .results = 0 }) catch {
|
||||
RemoteLua.sendNewLogEntry(Lua.state.toString(-1) catch unreachable);
|
||||
};
|
||||
Lua.state.pop(-1);
|
||||
Lua.state.protectedCall(.{ .args = 0, .results = 0 }) catch {
|
||||
RemoteLua.sendNewLogEntry(Lua.state.toString(-1) catch unreachable);
|
||||
};
|
||||
Lua.state.pop(-1);
|
||||
}
|
||||
|
||||
pub fn hash(modifier: wlr.Keyboard.ModifierMask, keycode: xkb.Keysym) u64 {
|
||||
const mod_val: u32 = @bitCast(modifier);
|
||||
const key_val: u32 = @intFromEnum(keycode);
|
||||
return (@as(u64, mod_val) << 32) | @as(u64, key_val);
|
||||
const mod_val: u32 = @bitCast(modifier);
|
||||
const key_val: u32 = @intFromEnum(keycode);
|
||||
return (@as(u64, mod_val) << 32) | @as(u64, key_val);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue