mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-08 04:57:32 -04:00
basic mousemap stuff, probably needs to be changed
This commit is contained in:
parent
afed68101c
commit
64dccb248d
4 changed files with 154 additions and 49 deletions
|
|
@ -62,6 +62,43 @@ pub fn add_keymap(L: *zlua.Lua) i32 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// ---Create a new mousemap
|
||||
/// ---@param string modifiers
|
||||
/// ---@param string button name (ex. "left", "right")
|
||||
/// ---@param table options
|
||||
pub fn add_mousemap(L: *zlua.Lua) i32 {
|
||||
var mousemap: Mousemap = undefined;
|
||||
// mousemap.options.repeat = true;
|
||||
|
||||
const mod = L.checkString(1);
|
||||
mousemap.modifier = parse_modkeys(mod);
|
||||
|
||||
const button = L.checkString(2);
|
||||
mousemap.keycode = xkb.Keysym.fromName(button, .no_flags);
|
||||
|
||||
_ = L.pushString("press");
|
||||
_ = L.getTable(3);
|
||||
if (L.isFunction(-1)) {
|
||||
keymap.options.lua_press_ref_idx = L.ref(zlua.registry_index) catch Utils.oomPanic();
|
||||
}
|
||||
|
||||
_ = L.pushString("release");
|
||||
_ = L.getTable(3);
|
||||
if (L.isFunction(-1)) {
|
||||
keymap.options.lua_release_ref_idx = L.ref(zlua.registry_index) catch Utils.oomPanic();
|
||||
}
|
||||
|
||||
_ = L.pushString("repeat");
|
||||
_ = L.getTable(3);
|
||||
keymap.options.repeat = L.isNil(-1) or L.toBoolean(-1);
|
||||
|
||||
const hash = Keymap.hash(mousemap.modifier, mousemap.keycode);
|
||||
server.mousemaps.put(hash, mousemap) catch Utils.oomPanic();
|
||||
|
||||
L.pushNil();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// ---Remove an existing keymap
|
||||
/// ---@param string modifiers
|
||||
/// ---@param string keys
|
||||
|
|
@ -83,6 +120,27 @@ pub fn del_keymap(L: *zlua.Lua) i32 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// ---Remove an existing mousemap
|
||||
/// ---@param string modifiers
|
||||
/// ---@param string button
|
||||
pub fn del_mousemap(L: *zlua.Lua) i32 {
|
||||
L.checkType(1, .string);
|
||||
L.checkType(2, .string);
|
||||
|
||||
var mousemap: Mousemap = undefined;
|
||||
const mod = L.checkString(1);
|
||||
|
||||
mousemap.modifier = parse_modkeys(mod);
|
||||
|
||||
const button = L.checkString(2);
|
||||
|
||||
mousemap.keycode = xkb.Keysym.fromName(button, .no_flags);
|
||||
_ = server.mousemaps.remove(Keymap.hash(mousemap.modifier, mousemap.keycode));
|
||||
|
||||
L.pushNil();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// ---Get the repeat information
|
||||
/// ---@return integer[2]
|
||||
pub fn get_repeat_info(L: *zlua.Lua) i32 {
|
||||
|
|
@ -110,3 +168,4 @@ pub fn set_repeat_info(L: *zlua.Lua) i32 {
|
|||
server.seat.keyboard_group.keyboard.setRepeatInfo(rate, delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue