diff options
author | ProgAndy <code@progandy.de> | 2018-07-25 17:08:47 +0200 |
---|---|---|
committer | ProgAndy <code@progandy.de> | 2018-07-25 17:24:45 +0200 |
commit | 0ba52458abb8fb0414319d2084e6d0d0214ae304 (patch) | |
tree | 9954d70e09b7d20b88451d523c5af73e29c55ab3 /sway/commands/input.c | |
parent | Add documentation for xkb_capslock/xkb_numlock (diff) | |
download | sway-0ba52458abb8fb0414319d2084e6d0d0214ae304.tar.gz sway-0ba52458abb8fb0414319d2084e6d0d0214ae304.tar.zst sway-0ba52458abb8fb0414319d2084e6d0d0214ae304.zip |
Restrict CapsLock and NumLock commands to the configuration file
Diffstat (limited to 'sway/commands/input.c')
-rw-r--r-- | sway/commands/input.c | 23 |
1 files changed, 20 insertions, 3 deletions
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[] = { | |||
24 | { "scroll_method", input_cmd_scroll_method }, | 24 | { "scroll_method", input_cmd_scroll_method }, |
25 | { "tap", input_cmd_tap }, | 25 | { "tap", input_cmd_tap }, |
26 | { "tap_button_map", input_cmd_tap_button_map }, | 26 | { "tap_button_map", input_cmd_tap_button_map }, |
27 | { "xkb_capslock", input_cmd_xkb_capslock }, | ||
28 | { "xkb_layout", input_cmd_xkb_layout }, | 27 | { "xkb_layout", input_cmd_xkb_layout }, |
29 | { "xkb_model", input_cmd_xkb_model }, | 28 | { "xkb_model", input_cmd_xkb_model }, |
30 | { "xkb_numlock", input_cmd_xkb_numlock }, | ||
31 | { "xkb_options", input_cmd_xkb_options }, | 29 | { "xkb_options", input_cmd_xkb_options }, |
32 | { "xkb_rules", input_cmd_xkb_rules }, | 30 | { "xkb_rules", input_cmd_xkb_rules }, |
33 | { "xkb_variant", input_cmd_xkb_variant }, | 31 | { "xkb_variant", input_cmd_xkb_variant }, |
34 | }; | 32 | }; |
35 | 33 | ||
34 | // must be in order for the bsearch | ||
35 | static struct cmd_handler input_config_handlers[] = { | ||
36 | { "xkb_capslock", input_cmd_xkb_capslock }, | ||
37 | { "xkb_numlock", input_cmd_xkb_numlock }, | ||
38 | }; | ||
39 | |||
36 | struct cmd_results *cmd_input(int argc, char **argv) { | 40 | struct cmd_results *cmd_input(int argc, char **argv) { |
37 | struct cmd_results *error = NULL; | 41 | struct cmd_results *error = NULL; |
38 | if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) { | 42 | if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) { |
@@ -46,8 +50,21 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
46 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); | 50 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); |
47 | } | 51 | } |
48 | 52 | ||
49 | struct cmd_results *res = config_subcommand(argv + 1, argc - 1, | 53 | struct cmd_results *res; |
54 | |||
55 | if (find_handler(argv[1], input_config_handlers, | ||
56 | sizeof(input_config_handlers))) { | ||
57 | if (config->reading) { | ||
58 | res = config_subcommand(argv + 1, argc - 1, | ||
59 | input_config_handlers, sizeof(input_config_handlers)); | ||
60 | } else { | ||
61 | res = cmd_results_new(CMD_FAILURE, "input", | ||
62 | "Can only be used in config file."); | ||
63 | } | ||
64 | } else { | ||
65 | res = config_subcommand(argv + 1, argc - 1, | ||
50 | input_handlers, sizeof(input_handlers)); | 66 | input_handlers, sizeof(input_handlers)); |
67 | } | ||
51 | 68 | ||
52 | free_input_config(config->handler_context.input_config); | 69 | free_input_config(config->handler_context.input_config); |
53 | config->handler_context.input_config = NULL; | 70 | config->handler_context.input_config = NULL; |