logo

inaban

Distrustful Wayland Compositor (inspired by XMonad and dwm) git clone https://hacktivis.me/git/inaban.git
commit: 4bad9c7aead8ec4ea8cc6cd24db236055adae4c8
parent 041e12b4aee66b4cf2625783861e390fc092223f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 10 May 2021 11:35:46 +0200

lock: Add quit shortcut

Diffstat:

Mconfig.h10+++++++++-
Minaban.c10++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/config.h b/config.h @@ -14,16 +14,24 @@ static const float locked_color[4] = {0.50f, 0.25f, 0.25f, 1.0f}; #define ModMask WLR_MODIFIER_ALT #define ShiftMask WLR_MODIFIER_SHIFT #define ModKey XKB_KEY_Alt_L + // clang-format off static Shortcut shortcuts[] = { /* modifier, keysym, function, argument */ // {ModMask, XKB_KEY_p, spawn, {.v = menucmd}}, {ModMask, XKB_KEY_Return, spawn, {.v = termcmd}}, - {ModMask | ShiftMask, XKB_KEY_q, quit, {0}}, + {ModMask & ShiftMask, XKB_KEY_q, quit, {0}}, {ModMask, XKB_KEY_l, lock, {0}}, // {MODKEY | ShiftMask, XKB_KEY_c, killclient, {0}}, // {MODKEY, XKB_KEY_j, focusstack, {.i = +1}}, // {MODKEY, XKB_KEY_k, focusstack, {.i = -1}}, }; // clang-format on + +// clang-format off +static Shortcut shortcuts_locked[] = { + /* modifier, keysym, function, argument */ + {ModMask & ShiftMask, XKB_KEY_q, quit, {0}}, +}; +// clang-format on #endif /* CONFIG_H */ diff --git a/inaban.c b/inaban.c @@ -61,6 +61,16 @@ keyboard_handle_key(struct wl_listener *listener, void *data) if(server->locked == true) { // needs to be written + switch(event->state) + { + case WL_KEYBOARD_KEY_STATE_PRESSED: + for(size_t i = 0; i < LENGTH(shortcuts_locked); i++) + if((keysym == shortcuts_locked[i].keysym) && (modifiers == shortcuts_locked[i].mod) && + shortcuts_locked[i].func) + { + shortcuts_locked[i].func(&(shortcuts_locked[i].arg)); + } + } return; }