mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
Do not segfault when loading an unknown keymap
This commit is contained in:
parent
f3769a4b1f
commit
2c31cac116
2 changed files with 15 additions and 5 deletions
|
@ -354,8 +354,16 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device,
|
||||||
wlr_log(L_ERROR, "Cannot create XKB context");
|
wlr_log(L_ERROR, "Cannot create XKB context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (keymap == NULL) {
|
||||||
|
xkb_context_unref(context);
|
||||||
|
wlr_log(L_ERROR, "Cannot create XKB keymap");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
|
|
||||||
int repeat_rate = (config->repeat_rate > 0) ? config->repeat_rate : 25;
|
int repeat_rate = (config->repeat_rate > 0) ? config->repeat_rate : 25;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
@ -132,9 +131,12 @@ void wlr_keyboard_led_update(struct wlr_keyboard *kb, uint32_t leds) {
|
||||||
|
|
||||||
void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
|
void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
|
||||||
struct xkb_keymap *keymap) {
|
struct xkb_keymap *keymap) {
|
||||||
wlr_log(L_DEBUG, "Keymap set");
|
kb->xkb_state = xkb_state_new(kb->keymap);
|
||||||
|
if (kb->xkb_state == NULL) {
|
||||||
|
wlr_log(L_ERROR, "Failed to create XKB state");
|
||||||
|
return;
|
||||||
|
}
|
||||||
kb->keymap = keymap;
|
kb->keymap = keymap;
|
||||||
assert(kb->xkb_state = xkb_state_new(kb->keymap));
|
|
||||||
|
|
||||||
const char *led_names[WLR_LED_COUNT] = {
|
const char *led_names[WLR_LED_COUNT] = {
|
||||||
XKB_LED_NAME_NUM,
|
XKB_LED_NAME_NUM,
|
||||||
|
|
Loading…
Reference in a new issue