From be2d2a299a6f854f0494f84169ef82ad5b31a917 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 23 May 2019 03:06:28 -0400 Subject: commands/input: perform basic keymap validation Before the delta input config is stored, this attempts to compile a keymap with it. If the keymap fails to compile, then the first line of the xkbcommon log entry will be included with a `CMD_FAILURE`, the entire xkbcommon log entry will be included in the sway error log, and the delta will not be stored. This only handles basic issues such as a layouts not existing. This will NOT catch more complex issues such as when a variant does exist, but not for the given layout (ex: `azerty` is a valid variant, but the `us` layout does not have a `azerty` variant). --- sway/commands/input.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sway/commands/input.c') diff --git a/sway/commands/input.c b/sway/commands/input.c index 0195082c..23a6644f 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c @@ -2,6 +2,7 @@ #include #include "sway/commands.h" #include "sway/input/input-manager.h" +#include "sway/input/keyboard.h" #include "log.h" #include "stringop.h" @@ -86,6 +87,20 @@ 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) { + if (res) { + free_cmd_results(res); + } + res = cmd_results_new(CMD_FAILURE, "Failed to compile keymap: %s", + error ? error : "(details unavailable)"); + free(error); + return res; + } + xkb_keymap_unref(keymap); + struct input_config *ic = store_input_config(config->handler_context.input_config); -- cgit v1.2.3-54-g00ecf