diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-02-07 13:46:29 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-02-08 09:09:14 +0000 |
| commit | 03bac9dada76690971943f824637407100f7a3ee (patch) | |
| tree | 86152095be7afb05878fbe4344ac6fe9c2c327f4 /config.h | |
| parent | Merge branch 'url-detection' (diff) | |
key-bindings: refactor: use a single type for all key bindings
Up until now, the various key binding modes (“normal”, “search” and
“url”) have used their own struct definitions for their key bindings.
The only reason for this was to have a properly typed “action” (using
the appropriate “action” enum).
This caused lots of duplicated code. This patch refactors this to use
a single struct definition for the “unparsed” key bindings handled by
the configuration, and another single definition for “parsed” bindings
used while handling input.
This allows us to implement configuration parsing, keymap translation
and so on using one set of functions, regardless of key binding mode.
Diffstat (limited to 'config.h')
| -rw-r--r-- | config.h | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -25,39 +25,26 @@ struct config_key_modifiers { bool meta; }; -struct config_key_binding_normal { - enum bind_action_normal action; - struct config_key_modifiers modifiers; - xkb_keysym_t sym; - struct { - char *cmd; - char **argv; - bool master_copy; - } pipe; -}; - -struct config_key_binding_search { - enum bind_action_search action; - struct config_key_modifiers modifiers; - xkb_keysym_t sym; +struct config_binding_pipe { + char *cmd; + char **argv; + bool master_copy; }; -struct config_key_binding_url { - enum bind_action_url action; +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; + struct config_binding_pipe pipe; }; +typedef tll(struct config_key_binding) config_key_binding_list_t; struct config_mouse_binding { enum bind_action_normal action; struct config_key_modifiers modifiers; int button; int count; - struct { - char *cmd; - char **argv; - bool master_copy; - } pipe; + struct config_binding_pipe pipe; }; /* If px != 0 then px is valid, otherwise pt is valid */ @@ -169,7 +156,7 @@ struct config { struct { /* Bindings for "normal" mode */ - tll(struct config_key_binding_normal) key; + config_key_binding_list_t key; tll(struct config_mouse_binding) mouse; /* @@ -178,10 +165,10 @@ struct config { /* While searching (not - action to *start* a search is in the * 'key' bindings above */ - tll(struct config_key_binding_search) search; + config_key_binding_list_t search; /* While showing URL jump labels */ - tll(struct config_key_binding_url) url; + config_key_binding_list_t url; } bindings; struct { |
