aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-11 19:41:32 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-11 19:41:32 -0500
commit21f42a86d7be1046a7ddc99487ab98d41fef2c8f (patch)
treea7e73d28df4ea5828f8270db3d5931631b902892 /dwl.c
parentdf1aaa4d159066f26ed4ff235fde9f60501c0618 (diff)
make key mappings configurable in config.h
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/dwl.c b/dwl.c
index a66d98d..24eeca3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -26,6 +26,8 @@
#include <wlr/util/log.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. */
enum dwl_cursor_mode {
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.
*/
- switch (sym) {
- case XKB_KEY_Escape:
- quit(server, NULL);
- break;
- case XKB_KEY_F1:
- focusnext(server, NULL);
- break;
- default:
- return false;
+ bool handled = false;
+ for (int i = 0; i < LENGTH(keys); i++) {
+ if (sym == keys[i].keysym && mods == keys[i].mod && keys[i].func) {
+ keys[i].func(server, &keys[i].arg);
+ handled = true;
+ }
}
- return true;
+ return handled;
}
static void keyboard_handle_key(