diff options
author | Konstantin Pospelov <kupospelov@gmail.com> | 2019-02-17 19:08:22 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-04-26 20:56:48 +0300 |
commit | a09c144b8b5f9d0518e7239a27e2fb86e00644b3 (patch) | |
tree | acce9b57c319496e9f5dd194e22e49b0b6fcbfdf /include/sway/config.h | |
parent | bd32b300fb61e31bcac76be470ff0faa65cf9a88 (diff) |
Implement bindsym --to-code
* `bindsym --to-code` enables keysym to keycode translation.
* If there are no `xkb_layout` commands in the config file, the translation
uses the XKB_DEFAULT_LAYOUT value.
* It there is one or more `xkb_layout` command, the translation uses
the first one.
* If the translation is unsuccessful, a message is logged and the binding
is stored as BINDING_KEYSYM.
* The binding keysyms are stored and re-translated when a change in the input
configuration may affect the translated bindings.
Diffstat (limited to 'include/sway/config.h')
-rw-r--r-- | include/sway/config.h | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 86410544..392f6538 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -24,7 +24,6 @@ struct sway_variable { char *value; }; - enum binding_input_type { BINDING_KEYCODE, BINDING_KEYSYM, @@ -39,6 +38,7 @@ enum binding_flags { BINDING_BORDER=4, // mouse only; trigger on container border BINDING_CONTENTS=8, // mouse only; trigger on container contents BINDING_TITLEBAR=16, // mouse only; trigger on container titlebar + BINDING_CODE=32, // keyboard only; convert keysyms into keycodes }; /** @@ -50,6 +50,7 @@ struct sway_binding { char *input; uint32_t flags; list_t *keys; // sorted in ascending order + list_t *syms; // sorted in ascending order; NULL if BINDING_CODE is not set uint32_t modifiers; char *command; }; @@ -407,6 +408,14 @@ enum alignment { }; /** + * The keysym to keycode translation. + */ +struct keysym_translation_data { + struct xkb_keymap *xkb_keymap; + struct xkb_state *xkb_state; +}; + +/** * The configuration struct. The result of loading a config file. */ struct sway_config { @@ -508,6 +517,9 @@ struct sway_config { list_t *feature_policies; list_t *ipc_policies; + // The keysym to keycode translation + struct keysym_translation_data keysym_translation; + // Context for command handlers struct { struct input_config *input_config; @@ -617,12 +629,6 @@ bool spawn_swaybg(void); int workspace_output_cmp_workspace(const void *a, const void *b); -int sway_binding_cmp(const void *a, const void *b); - -int sway_binding_cmp_qsort(const void *a, const void *b); - -int sway_binding_cmp_keys(const void *a, const void *b); - void free_sway_binding(struct sway_binding *sb); void free_switch_binding(struct sway_switch_binding *binding); @@ -651,6 +657,16 @@ void free_workspace_config(struct workspace_config *wsc); */ void config_update_font_height(bool recalculate); +/** + * Convert bindsym into bindcode using the first configured layout. + * Return false in case the conversion is unsuccessful. + */ +bool translate_binding(struct sway_binding *binding); + +void translate_keysyms(const char *layout); + +void binding_add_translated(struct sway_binding *binding, list_t *bindings); + /* Global config singleton. */ extern struct sway_config *config; |