From d07463d53b2677ba0662b2b91aad484f67fc6405 Mon Sep 17 00:00:00 2001 From: ProgAndy Date: Mon, 23 Jul 2018 14:41:11 +0200 Subject: Add documentation for xkb_capslock/xkb_numlock --- sway/sway-input.5.scd | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sway/sway-input.5.scd') diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index b6391431..372ca697 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -33,6 +33,14 @@ For more information on these xkb configuration options, see *input* xkb\_variant Sets the variant of the keyboard like _dvorak_ or _colemak_. +*input* xkb\_capslock enabled|disabled + Enables or disables CapsLock on sway startup, the default is disabled. + Only meaningful if sway controls the keyboard. + +*input* xkb\_numlock enabled|disabled + Enables or disables NumLock on sway startup, the default is enabled. + Only meaningful if sway controls the keyboard. + ## MAPPING CONFIGURATION *input* map\_to\_output -- cgit v1.2.3 From 0ba52458abb8fb0414319d2084e6d0d0214ae304 Mon Sep 17 00:00:00 2001 From: ProgAndy Date: Wed, 25 Jul 2018 17:08:47 +0200 Subject: Restrict CapsLock and NumLock commands to the configuration file --- sway/commands/input.c | 23 ++++++++++++++++++++--- sway/sway-input.5.scd | 8 ++++---- 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'sway/sway-input.5.scd') diff --git a/sway/commands/input.c b/sway/commands/input.c index 7f927073..84888fbb 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c @@ -24,15 +24,19 @@ static struct cmd_handler input_handlers[] = { { "scroll_method", input_cmd_scroll_method }, { "tap", input_cmd_tap }, { "tap_button_map", input_cmd_tap_button_map }, - { "xkb_capslock", input_cmd_xkb_capslock }, { "xkb_layout", input_cmd_xkb_layout }, { "xkb_model", input_cmd_xkb_model }, - { "xkb_numlock", input_cmd_xkb_numlock }, { "xkb_options", input_cmd_xkb_options }, { "xkb_rules", input_cmd_xkb_rules }, { "xkb_variant", input_cmd_xkb_variant }, }; +// must be in order for the bsearch +static struct cmd_handler input_config_handlers[] = { + { "xkb_capslock", input_cmd_xkb_capslock }, + { "xkb_numlock", input_cmd_xkb_numlock }, +}; + struct cmd_results *cmd_input(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) { @@ -46,8 +50,21 @@ struct cmd_results *cmd_input(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); } - struct cmd_results *res = config_subcommand(argv + 1, argc - 1, + struct cmd_results *res; + + if (find_handler(argv[1], input_config_handlers, + sizeof(input_config_handlers))) { + if (config->reading) { + res = config_subcommand(argv + 1, argc - 1, + input_config_handlers, sizeof(input_config_handlers)); + } else { + res = cmd_results_new(CMD_FAILURE, "input", + "Can only be used in config file."); + } + } else { + res = config_subcommand(argv + 1, argc - 1, input_handlers, sizeof(input_handlers)); + } free_input_config(config->handler_context.input_config); config->handler_context.input_config = NULL; diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 372ca697..fa311971 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -33,13 +33,13 @@ For more information on these xkb configuration options, see *input* xkb\_variant Sets the variant of the keyboard like _dvorak_ or _colemak_. +The following commands may only be used in the configuration file. + *input* xkb\_capslock enabled|disabled - Enables or disables CapsLock on sway startup, the default is disabled. - Only meaningful if sway controls the keyboard. + Initially enables or disables CapsLock, the default is disabled. *input* xkb\_numlock enabled|disabled - Enables or disables NumLock on sway startup, the default is enabled. - Only meaningful if sway controls the keyboard. + Initially enables or disables NumLock, the default is enabled. ## MAPPING CONFIGURATION -- cgit v1.2.3 From 30fee94354b61c2604431a53f4d1a1daf6c0a67a Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Fri, 27 Jul 2018 22:42:50 -0700 Subject: Don't enable numlock by default. This fixes an annoying issue where laptop keyboards would have 'numlock mode' enabled, remapping parts of the alphabet to numbers. --- sway/input/keyboard.c | 2 +- sway/sway-input.5.scd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/sway-input.5.scd') diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 643ff510..8dc8239c 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -387,7 +387,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); xkb_mod_mask_t locked_mods = 0; - if (!input_config || input_config->xkb_numlock != 0) { + if (input_config && input_config->xkb_numlock > 0) { xkb_mod_index_t mod_index = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_NUM); if (mod_index != XKB_MOD_INVALID) { locked_mods |= (uint32_t)1 << mod_index; diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index fa311971..b2395273 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -39,7 +39,7 @@ The following commands may only be used in the configuration file. Initially enables or disables CapsLock, the default is disabled. *input* xkb\_numlock enabled|disabled - Initially enables or disables NumLock, the default is enabled. + Initially enables or disables NumLock, the default is disabled. ## MAPPING CONFIGURATION -- cgit v1.2.3 From 7b9aee5451a08f63d9f9effed286cdb0339b4e5b Mon Sep 17 00:00:00 2001 From: Marius Orcsik Date: Sun, 29 Jul 2018 14:47:53 +0200 Subject: Escaping underscores in tap_button_map --- sway/sway-input.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/sway-input.5.scd') diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index b2395273..707c36af 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -108,7 +108,7 @@ The following commands may only be used in the configuration file. *input* tap enabled|disabled Enables or disables tap for specified input device. -*input* tap_button_map lrm|lmr +*input* tap\_button\_map lrm|lmr Specifies which button mapping to use for tapping. _lrm_ treats 1 finger as left click, 2 fingers as right click, and 3 fingers as middle click. _lmr_ treats 1 finger as left click, 2 fingers as middle click, and 3 fingers as -- cgit v1.2.3