Skip to content

Commit

Permalink
keyboard: check xkb options for errors
Browse files Browse the repository at this point in the history
Fixes #590
Fixes #456
  • Loading branch information
ammen99 committed Jul 19, 2020
1 parent fa466b5 commit f8f47cf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/core/seat/keyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <string.h>
#include <cstring>
#include <linux/input-event-codes.h>

extern "C"
Expand All @@ -7,6 +7,7 @@ extern "C"
#include <wlr/backend/session.h>
}

#include <wayfire/util/log.hpp>
#include "keyboard.hpp"
#include "../core-impl.hpp"
#include "../../output/output-impl.hpp"
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit f8f47cf

Please sign in to comment.