make key mappings configurable in config.h

This commit is contained in:
Devin J. Pohly 2020-04-11 19:41:32 -05:00
parent df1aaa4d15
commit 21f42a86d7

19
dwl.c
View file

@ -26,6 +26,8 @@
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#define LENGTH(X) (sizeof X / sizeof X[0])
/* For brevity's sake, struct members are annotated where they are used. */ /* For brevity's sake, struct members are annotated where they are used. */
enum dwl_cursor_mode { enum dwl_cursor_mode {
DWL_CURSOR_PASSTHROUGH, DWL_CURSOR_PASSTHROUGH,
@ -193,17 +195,14 @@ static bool handle_keybinding(struct dwl_server *server, uint32_t mods, xkb_keys
* processing keys, rather than passing them on to the client for its own * processing keys, rather than passing them on to the client for its own
* processing. * processing.
*/ */
switch (sym) { bool handled = false;
case XKB_KEY_Escape: for (int i = 0; i < LENGTH(keys); i++) {
quit(server, NULL); if (sym == keys[i].keysym && mods == keys[i].mod && keys[i].func) {
break; keys[i].func(server, &keys[i].arg);
case XKB_KEY_F1: handled = true;
focusnext(server, NULL); }
break;
default:
return false;
} }
return true; return handled;
} }
static void keyboard_handle_key( static void keyboard_handle_key(