Skip to content

Commit

Permalink
wayland: replace old keymap if we receive a new keymap event
Browse files Browse the repository at this point in the history
Fixes: 2274311
Fixes: #15022
  • Loading branch information
llyyr authored and sfan5 committed Oct 8, 2024
1 parent c201c48 commit 6871304
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,12 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
return;
}

if (!s->xkb_keymap)
s->xkb_keymap = xkb_keymap_new_from_buffer(wl->xkb_context, map_str,
strnlen(map_str, size),
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
if (s->xkb_keymap)
xkb_keymap_unref(s->xkb_keymap);

s->xkb_keymap = xkb_keymap_new_from_buffer(wl->xkb_context, map_str,
strnlen(map_str, size),
XKB_KEYMAP_FORMAT_TEXT_V1, 0);

munmap(map_str, size);
close(fd);
Expand All @@ -540,9 +542,10 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
MP_ERR(wl, "failed to compile keymap\n");
return;
}
if (s->xkb_state)
xkb_state_unref(s->xkb_state);

if (!s->xkb_state)
s->xkb_state = xkb_state_new(s->xkb_keymap);
s->xkb_state = xkb_state_new(s->xkb_keymap);
if (!s->xkb_state) {
MP_ERR(wl, "failed to create XKB state\n");
xkb_keymap_unref(s->xkb_keymap);
Expand Down

0 comments on commit 6871304

Please sign in to comment.