From 7ec472cd2268c0f4e341148b8f781923d0515ac6 Mon Sep 17 00:00:00 2001 From: Simon Long Date: Wed, 5 Jun 2024 09:41:14 +0100 Subject: [PATCH] Change variable name; add key_remove --- include/config/keybind.h | 2 +- src/config/keybind.c | 6 +++--- src/input/keyboard.c | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/config/keybind.h b/include/config/keybind.h index 139442e5..a6ac0a09 100644 --- a/include/config/keybind.h +++ b/include/config/keybind.h @@ -20,7 +20,7 @@ struct keybind { int keycodes_layout; struct wl_list actions; /* struct action.link */ struct wl_list link; /* struct rcxml.keybinds */ - bool mod_only; /* set if only modifier keys used */ + bool on_release; /* set if only modifier keys used */ }; /** diff --git a/src/config/keybind.c b/src/config/keybind.c index c0d8362a..9d446f3e 100644 --- a/src/config/keybind.c +++ b/src/config/keybind.c @@ -122,7 +122,7 @@ keybind_create(const char *keybind) xkb_keysym_t sym; struct keybind *k = znew(*k); xkb_keysym_t keysyms[MAX_KEYSYMS]; - bool mod_only = TRUE; + bool on_release = true; gchar **symnames = g_strsplit(keybind, "-", -1); for (size_t i = 0; symnames[i]; i++) { char *symname = symnames[i]; @@ -132,7 +132,7 @@ keybind_create(const char *keybind) } else { sym = xkb_keysym_from_name(symname, XKB_KEYSYM_CASE_INSENSITIVE); if (!keyboard_is_modifier_key(sym)) { - mod_only = FALSE; + on_release = false; } if (sym == XKB_KEY_NoSymbol && g_utf8_strlen(symname, -1) == 1) { /* @@ -168,7 +168,7 @@ keybind_create(const char *keybind) if (!k) { return NULL; } - k->mod_only = mod_only; + k->on_release = on_release; wl_list_append(&rc.keybinds, &k->link); k->keysyms = xmalloc(k->keysyms_len * sizeof(xkb_keysym_t)); memcpy(k->keysyms, keysyms, k->keysyms_len * sizeof(xkb_keysym_t)); diff --git a/src/input/keyboard.c b/src/input/keyboard.c index 11fe0181..a709675f 100644 --- a/src/input/keyboard.c +++ b/src/input/keyboard.c @@ -38,7 +38,7 @@ struct keyinfo { static bool should_cancel_cycling_on_next_key_release; -struct keybind *cur_keybind; +static struct keybind *cur_keybind; static void change_vt(struct server *server, unsigned int vt) @@ -409,11 +409,12 @@ handle_compositor_keybindings(struct keyboard *keyboard, keyinfo.is_modifier); if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) { - if (cur_keybind && cur_keybind->mod_only) { + if (cur_keybind && cur_keybind->on_release) { + key_state_bound_key_remove(event->keycode); if (seat->active_client_while_inhibited || seat->server->session_lock) { cur_keybind = NULL; - return false; + return true; } actions_run(NULL, server, &cur_keybind->actions, 0); cur_keybind = NULL; @@ -465,7 +466,7 @@ handle_compositor_keybindings(struct keyboard *keyboard, * 'pressed-sent' keys to the new surface. */ key_state_store_pressed_key_as_bound(event->keycode); - if (!cur_keybind->mod_only) { + if (!cur_keybind->on_release) { actions_run(NULL, server, &cur_keybind->actions, 0); cur_keybind = NULL; }