From 5b1a8d62b9c8fa7c25b70e01910abd761fae9855 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 5 Jun 2019 14:16:37 -0400 Subject: 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. --- sway/commands/input.c | 11 ++++------- sway/commands/input/events.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'sway/commands') 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) { if (!res || res->status == CMD_SUCCESS) { char *error = NULL; - struct xkb_keymap *keymap = sway_keyboard_compile_keymap( - config->handler_context.input_config, &error); - if (!keymap) { + struct input_config *ic = + store_input_config(config->handler_context.input_config, &error); + if (!ic) { + free_input_config(config->handler_context.input_config); if (res) { free_cmd_results(res); } @@ -99,10 +100,6 @@ struct cmd_results *cmd_input(int argc, char **argv) { free(error); return res; } - xkb_keymap_unref(keymap); - - struct input_config *ic = - store_input_config(config->handler_context.input_config); input_manager_apply_input_config(ic); retranslate_keysyms(ic); diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c index 44bc9e74..cd2985ee 100644 --- a/sway/commands/input/events.c +++ b/sway/commands/input/events.c @@ -101,7 +101,7 @@ static void toggle_wildcard_send_events(int argc, char **argv) { } else { toggle_supported_send_events_for_device(ic, input_device); } - store_input_config(ic); + store_input_config(ic, NULL); } } -- cgit v1.2.3