aboutsummaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-06 20:04:38 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-11 19:19:11 +0000
commitf6a591b80a820ae5ab6886eb9ba43c90986f302b (patch)
tree142fc28bab22e058505cccb6fe104442b64ebe01 /config.h
parentconfig: do mouse binding collision detection after loading the conf (diff)
config: unify key- and mouse bindings
With this patch, key- and mouse-bindings structs (the non-layout specific ones) are unified into a single struct. The logic that parses, and manages, the key- and mouse binding lists are almost identical. The *only* difference between a key- and a mouse binding is that key bindings have an XKB symbol, and mouse bindings a button and click-count. The new, unified, struct uses a union around these, and all functions that need to know which members to use/operate on now takes a ‘type’ parameter.
Diffstat (limited to 'config.h')
-rw-r--r--config.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/config.h b/config.h
index 153b9c27..4a724bec 100644
--- a/config.h
+++ b/config.h
@@ -40,10 +40,27 @@ struct config_binding_pipe {
bool master_copy;
};
+enum config_key_binding_type {
+ KEY_BINDING,
+ MOUSE_BINDING,
+};
+
struct config_key_binding {
int action; /* One of the varios bind_action_* enums from wayland.h */
struct config_key_modifiers modifiers;
- xkb_keysym_t sym;
+ union {
+ /* Key bindings */
+ struct {
+ xkb_keysym_t sym;
+ } k;
+
+ /* Mouse bindings */
+ struct {
+ int button;
+ int count;
+ } m;
+ };
+
struct config_binding_pipe pipe;
/* For error messages in collision handling */
@@ -52,6 +69,7 @@ struct config_key_binding {
};
DEFINE_LIST(struct config_key_binding);
+#if 0
struct config_mouse_binding {
enum bind_action_normal action;
struct config_key_modifiers modifiers;
@@ -64,6 +82,7 @@ struct config_mouse_binding {
int lineno;
};
DEFINE_LIST(struct config_mouse_binding);
+#endif
typedef tll(char *) config_override_t;
@@ -207,7 +226,7 @@ struct config {
struct {
/* Bindings for "normal" mode */
struct config_key_binding_list key;
- struct config_mouse_binding_list mouse;
+ struct config_key_binding_list mouse;
/*
* Special modes