From f8f47cf7b367eb4e69cc48eb57919af8071c84b9 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Sun, 19 Jul 2020 16:26:29 +0200 Subject: [PATCH] keyboard: check xkb options for errors Fixes #590 Fixes #456 --- src/core/seat/keyboard.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/seat/keyboard.cpp b/src/core/seat/keyboard.cpp index e8708d058..c06e4cb01 100644 --- a/src/core/seat/keyboard.cpp +++ b/src/core/seat/keyboard.cpp @@ -1,4 +1,4 @@ -#include +#include #include extern "C" @@ -7,6 +7,7 @@ extern "C" #include } +#include #include "keyboard.hpp" #include "../core-impl.hpp" #include "../../output/output-impl.hpp" @@ -77,7 +78,6 @@ void wf_keyboard::reload_input_options() std::string variant = this->variant; std::string options = this->options; - xkb_rule_names names; names.rules = rules.c_str(); names.model = model.c_str(); @@ -87,6 +87,17 @@ void wf_keyboard::reload_input_options() auto keymap = xkb_map_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); + if (!keymap) + { + LOGE("Could not create keymap with given configuration:", + " rules=\"", rules, "\" model=\"", model, "\" layout=\"",layout, + "\" variant=\"", variant, "\" options=\"", options, "\""); + + // reset to NULL + std::memset(&names, 0, sizeof(names)); + keymap = xkb_map_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); + } + wlr_keyboard_set_keymap(handle, keymap); xkb_keymap_unref(keymap); xkb_context_unref(ctx);