summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-08-15 09:32:11 -0500
committerDudemanguy <random342@airmail.cc>2021-08-15 09:45:23 -0500
commite0df7688f63d57f4f72c99977bd4cedb33e59a71 (patch)
tree0ee3b9a9022fad2db61fc93dd7cdee37d861d34b
parent0c9e1e34fddb35e9b4205cee4ce6810e4a7388ee (diff)
downloadmpv-e0df7688f63d57f4f72c99977bd4cedb33e59a71.tar.bz2
mpv-e0df7688f63d57f4f72c99977bd4cedb33e59a71.tar.xz
wayland: check for xkb state in handle modifiers
Normally in wayland, you receive a keymap event from the compositor which is what allows the client to setup what is needed for xkb. However, it turns out that this doesn't occur in the case of virtual keyboards, such as from wtype, that come from the custom virtual-keyboard protocol. What happens in this case is that mpv only receives a keyboard entrance event. According to the wayland protocol documentation [1], "the compositor must send wl_keyboard.modifiers event after [the wl_keyboard.enter] event". It is possible for this to occur before the physical keyboard is properly mapped (i.e: using a virtual keyboard to start mpv). What this results in is a segfault once xkb_state_update_mask is called in the modifiers event. The fix is to simply not always assume we have created the xkb state if we get this event and check for its existence first. Closes #9119. https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard
-rw-r--r--video/out/wayland_common.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 6311e34d13..9b901d9f40 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -395,7 +395,6 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
state = state == WL_KEYBOARD_KEY_STATE_PRESSED ? MP_KEY_STATE_DOWN
: MP_KEY_STATE_UP;
-
int mpmod = get_mods(wl);
int mpkey = lookupkey(sym);
if (mpkey) {
@@ -414,8 +413,10 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboar
{
struct vo_wayland_state *wl = data;
- xkb_state_update_mask(wl->xkb_state, mods_depressed, mods_latched,
- mods_locked, 0, 0, group);
+ if (wl->xkb_state) {
+ xkb_state_update_mask(wl->xkb_state, mods_depressed, mods_latched,
+ mods_locked, 0, 0, group);
+ }
}
static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard,