36
src/Config.c
36
src/Config.c
@@ -263,33 +263,19 @@ void config_unref(lua_State *L, Config *cfg)
|
||||
cfg->input.keyboard.xkb_options = NULL;
|
||||
}
|
||||
|
||||
int trigger_ref_modsym(
|
||||
lua_State *L, Config const *cfg, uint32_t mods, xkb_keysym_t sym)
|
||||
void config_trigger_ref(lua_State *L, Config *cfg, int ref)
|
||||
{
|
||||
if (!L || !cfg)
|
||||
return -1;
|
||||
|
||||
for (size_t i = 0; i < cfg->keybindings.count; ++i) {
|
||||
BindingRef const *br = &cfg->keybindings.items[i];
|
||||
if (br->sym != sym)
|
||||
continue;
|
||||
if ((mods & br->mods_mask) != br->mods_mask)
|
||||
continue;
|
||||
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, br->action_ref);
|
||||
if (!lua_isfunction(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
|
||||
fprintf(stderr, "config: action error: %s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
||||
if (!lua_isfunction(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
|
||||
fprintf(stderr, "config: action error: %s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
return;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int load_config_file(lua_State *L, char const *path)
|
||||
|
||||
Reference in New Issue
Block a user