mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
keyboard: use 'us' as fallback for XKB_DEFAULT_LAYOUT
...if keymap cannot be created for the provided XKB_DEFAULT_LAYOUT. If keymap still cannot be created, exit with a helpful message to avoid crash that is hard to understand. Fixes: https://github.com/stefonarch/lxqt-labwc-session/issues/7
This commit is contained in:
parent
1e1e90d0bb
commit
5cb3583108
2 changed files with 17 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/backend/multi.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/interfaces/wlr_keyboard.h>
|
||||
|
|
@ -628,6 +630,8 @@ reset_window_keyboard_layout_groups(struct server *server)
|
|||
static void
|
||||
set_layout(struct server *server, struct wlr_keyboard *kb)
|
||||
{
|
||||
static bool fallback_mode;
|
||||
|
||||
struct xkb_rule_names rules = { 0 };
|
||||
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||
|
|
@ -639,7 +643,14 @@ set_layout(struct server *server, struct wlr_keyboard *kb)
|
|||
}
|
||||
xkb_keymap_unref(keymap);
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Failed to create xkb keymap");
|
||||
wlr_log(WLR_ERROR, "failed to create xkb keymap for layout '%s'",
|
||||
getenv("XKB_DEFAULT_LAYOUT"));
|
||||
if (!fallback_mode) {
|
||||
wlr_log(WLR_ERROR, "entering fallback mode with layout 'us'");
|
||||
fallback_mode = true;
|
||||
setenv("XKB_DEFAULT_LAYOUT", "us", 1);
|
||||
set_layout(server, kb);
|
||||
}
|
||||
}
|
||||
xkb_context_unref(context);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue