aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/config.h
diff options
context:
space:
mode:
authorLibravatar Konstantin Pospelov <kupospelov@gmail.com>2019-02-17 19:08:22 +0300
committerLibravatar Simon Ser <contact@emersion.fr>2019-04-26 20:56:48 +0300
commita09c144b8b5f9d0518e7239a27e2fb86e00644b3 (patch)
treeacce9b57c319496e9f5dd194e22e49b0b6fcbfdf /include/sway/config.h
parentci: enable all features (diff)
downloadsway-a09c144b8b5f9d0518e7239a27e2fb86e00644b3.tar.gz
sway-a09c144b8b5f9d0518e7239a27e2fb86e00644b3.tar.zst
sway-a09c144b8b5f9d0518e7239a27e2fb86e00644b3.zip
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.h30
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 {
24 char *value; 24 char *value;
25}; 25};
26 26
27
28enum binding_input_type { 27enum binding_input_type {
29 BINDING_KEYCODE, 28 BINDING_KEYCODE,
30 BINDING_KEYSYM, 29 BINDING_KEYSYM,
@@ -39,6 +38,7 @@ enum binding_flags {
39 BINDING_BORDER=4, // mouse only; trigger on container border 38 BINDING_BORDER=4, // mouse only; trigger on container border
40 BINDING_CONTENTS=8, // mouse only; trigger on container contents 39 BINDING_CONTENTS=8, // mouse only; trigger on container contents
41 BINDING_TITLEBAR=16, // mouse only; trigger on container titlebar 40 BINDING_TITLEBAR=16, // mouse only; trigger on container titlebar
41 BINDING_CODE=32, // keyboard only; convert keysyms into keycodes
42}; 42};
43 43
44/** 44/**
@@ -50,6 +50,7 @@ struct sway_binding {
50 char *input; 50 char *input;
51 uint32_t flags; 51 uint32_t flags;
52 list_t *keys; // sorted in ascending order 52 list_t *keys; // sorted in ascending order
53 list_t *syms; // sorted in ascending order; NULL if BINDING_CODE is not set
53 uint32_t modifiers; 54 uint32_t modifiers;
54 char *command; 55 char *command;
55}; 56};
@@ -407,6 +408,14 @@ enum alignment {
407}; 408};
408 409
409/** 410/**
411 * The keysym to keycode translation.
412 */
413struct keysym_translation_data {
414 struct xkb_keymap *xkb_keymap;
415 struct xkb_state *xkb_state;
416};
417
418/**
410 * The configuration struct. The result of loading a config file. 419 * The configuration struct. The result of loading a config file.
411 */ 420 */
412struct sway_config { 421struct sway_config {
@@ -508,6 +517,9 @@ struct sway_config {
508 list_t *feature_policies; 517 list_t *feature_policies;
509 list_t *ipc_policies; 518 list_t *ipc_policies;
510 519
520 // The keysym to keycode translation
521 struct keysym_translation_data keysym_translation;
522
511 // Context for command handlers 523 // Context for command handlers
512 struct { 524 struct {
513 struct input_config *input_config; 525 struct input_config *input_config;
@@ -617,12 +629,6 @@ bool spawn_swaybg(void);
617 629
618int workspace_output_cmp_workspace(const void *a, const void *b); 630int workspace_output_cmp_workspace(const void *a, const void *b);
619 631
620int sway_binding_cmp(const void *a, const void *b);
621
622int sway_binding_cmp_qsort(const void *a, const void *b);
623
624int sway_binding_cmp_keys(const void *a, const void *b);
625
626void free_sway_binding(struct sway_binding *sb); 632void free_sway_binding(struct sway_binding *sb);
627 633
628void free_switch_binding(struct sway_switch_binding *binding); 634void free_switch_binding(struct sway_switch_binding *binding);
@@ -651,6 +657,16 @@ void free_workspace_config(struct workspace_config *wsc);
651 */ 657 */
652void config_update_font_height(bool recalculate); 658void config_update_font_height(bool recalculate);
653 659
660/**
661 * Convert bindsym into bindcode using the first configured layout.
662 * Return false in case the conversion is unsuccessful.
663 */
664bool translate_binding(struct sway_binding *binding);
665
666void translate_keysyms(const char *layout);
667
668void binding_add_translated(struct sway_binding *binding, list_t *bindings);
669
654/* Global config singleton. */ 670/* Global config singleton. */
655extern struct sway_config *config; 671extern struct sway_config *config;
656 672