mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
keyboard: fix bug with empty XKB_DEFAULT_LAYOUT
With XKB_DEFAULT_LAYOUT= (set to empty rather than unset) the keyboard just does not work. Ref: https://github.com/labwc/labwc-tweaks/issues/89
This commit is contained in:
parent
f20b2c7632
commit
72df8fe73c
1 changed files with 10 additions and 2 deletions
|
|
@ -698,7 +698,15 @@ set_layout(struct server *server, struct wlr_keyboard *kb)
|
|||
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
if (keymap) {
|
||||
|
||||
/*
|
||||
* With XKB_DEFAULT_LAYOUT set to empty odd things happen with
|
||||
* xkb_map_new_from_names() resulting in the keyboard not working, so
|
||||
* we protect against that.
|
||||
*/
|
||||
const char *layout = getenv("XKB_DEFAULT_LAYOUT");
|
||||
bool layout_empty = layout && !*layout;
|
||||
if (keymap && !layout_empty) {
|
||||
if (!wlr_keyboard_keymaps_match(kb->keymap, keymap)) {
|
||||
wlr_keyboard_set_keymap(kb, keymap);
|
||||
reset_window_keyboard_layout_groups(server);
|
||||
|
|
@ -706,7 +714,7 @@ set_layout(struct server *server, struct wlr_keyboard *kb)
|
|||
xkb_keymap_unref(keymap);
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "failed to create xkb keymap for layout '%s'",
|
||||
getenv("XKB_DEFAULT_LAYOUT"));
|
||||
layout);
|
||||
if (!fallback_mode) {
|
||||
wlr_log(WLR_ERROR, "entering fallback mode with layout 'us'");
|
||||
fallback_mode = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue