diff options
-rw-r--r-- | sway/config.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c index 568c8b53..d46b81ee 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -43,13 +43,20 @@ static struct xkb_state *keysym_translation_state_create( | |||
43 | context, | 43 | context, |
44 | &rules, | 44 | &rules, |
45 | XKB_KEYMAP_COMPILE_NO_FLAGS); | 45 | XKB_KEYMAP_COMPILE_NO_FLAGS); |
46 | |||
47 | xkb_context_unref(context); | 46 | xkb_context_unref(context); |
47 | if (xkb_keymap == NULL) { | ||
48 | sway_log(SWAY_ERROR, "Failed to compile keysym translation XKB keymap"); | ||
49 | return NULL; | ||
50 | } | ||
51 | |||
48 | return xkb_state_new(xkb_keymap); | 52 | return xkb_state_new(xkb_keymap); |
49 | } | 53 | } |
50 | 54 | ||
51 | static void keysym_translation_state_destroy( | 55 | static void keysym_translation_state_destroy( |
52 | struct xkb_state *state) { | 56 | struct xkb_state *state) { |
57 | if (state == NULL) { | ||
58 | return; | ||
59 | } | ||
53 | xkb_keymap_unref(xkb_state_get_keymap(state)); | 60 | xkb_keymap_unref(xkb_state_get_keymap(state)); |
54 | xkb_state_unref(state); | 61 | xkb_state_unref(state); |
55 | } | 62 | } |
@@ -339,6 +346,9 @@ static void config_defaults(struct sway_config *config) { | |||
339 | struct xkb_rule_names rules = {0}; | 346 | struct xkb_rule_names rules = {0}; |
340 | config->keysym_translation_state = | 347 | config->keysym_translation_state = |
341 | keysym_translation_state_create(rules); | 348 | keysym_translation_state_create(rules); |
349 | if (config->keysym_translation_state == NULL) { | ||
350 | goto cleanup; | ||
351 | } | ||
342 | 352 | ||
343 | return; | 353 | return; |
344 | cleanup: | 354 | cleanup: |
@@ -987,6 +997,11 @@ void translate_keysyms(struct input_config *input_config) { | |||
987 | input_config_fill_rule_names(input_config, &rules); | 997 | input_config_fill_rule_names(input_config, &rules); |
988 | config->keysym_translation_state = | 998 | config->keysym_translation_state = |
989 | keysym_translation_state_create(rules); | 999 | keysym_translation_state_create(rules); |
1000 | if (config->keysym_translation_state == NULL) { | ||
1001 | sway_log(SWAY_ERROR, "Failed to create keysym translation XKB state " | ||
1002 | "for device '%s'", input_config->identifier); | ||
1003 | return; | ||
1004 | } | ||
990 | 1005 | ||
991 | for (int i = 0; i < config->modes->length; ++i) { | 1006 | for (int i = 0; i < config->modes->length; ++i) { |
992 | struct sway_mode *mode = config->modes->items[i]; | 1007 | struct sway_mode *mode = config->modes->items[i]; |