aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/input.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-06-05 14:16:37 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2019-06-09 20:13:22 +0300
commit5b1a8d62b9c8fa7c25b70e01910abd761fae9855 (patch)
tree173ef18191acf9dfb84b3bb76c43ee8108f4cd89 /sway/commands/input.c
parentcommands/input: perform basic keymap validation (diff)
downloadsway-5b1a8d62b9c8fa7c25b70e01910abd761fae9855.tar.gz
sway-5b1a8d62b9c8fa7c25b70e01910abd761fae9855.tar.zst
sway-5b1a8d62b9c8fa7c25b70e01910abd761fae9855.zip
config/input: validate xkb keymap before storing
This allows for an optional validation stage when storing an input config. Currently, only the xkb keymap is validated. If storing the delta input config will result in any invalid xkb keymaps, the input config will not be stored and error will be populated with the first line of the xkbcommon log.
Diffstat (limited to 'sway/commands/input.c')
-rw-r--r--sway/commands/input.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 23a6644f..d95c4baf 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -88,9 +88,10 @@ struct cmd_results *cmd_input(int argc, char **argv) {
88 88
89 if (!res || res->status == CMD_SUCCESS) { 89 if (!res || res->status == CMD_SUCCESS) {
90 char *error = NULL; 90 char *error = NULL;
91 struct xkb_keymap *keymap = sway_keyboard_compile_keymap( 91 struct input_config *ic =
92 config->handler_context.input_config, &error); 92 store_input_config(config->handler_context.input_config, &error);
93 if (!keymap) { 93 if (!ic) {
94 free_input_config(config->handler_context.input_config);
94 if (res) { 95 if (res) {
95 free_cmd_results(res); 96 free_cmd_results(res);
96 } 97 }
@@ -99,10 +100,6 @@ struct cmd_results *cmd_input(int argc, char **argv) {
99 free(error); 100 free(error);
100 return res; 101 return res;
101 } 102 }
102 xkb_keymap_unref(keymap);
103
104 struct input_config *ic =
105 store_input_config(config->handler_context.input_config);
106 103
107 input_manager_apply_input_config(ic); 104 input_manager_apply_input_config(ic);
108 retranslate_keysyms(ic); 105 retranslate_keysyms(ic);