Skip to content
Snippets Groups Projects
Commit 74be5334 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

dix: pick the right keyboard for focus FollowKeyboard


This fixes a crash when we try to send focus events and dereference
FollowKeyboardWin (0x3) as WindowPtr.

A device set to XSetDeviceFocus(FollowKeyboard) is supposed to follow
the focus of the corresponding master device. During ActivateKeyboard
a slave device is detached from the master for the duration for the grab
so we don't actually have a master to follow - leaving our oldWin set to
the FollowKeyboardWin constant. This later crashes when we try to
dereference it.

Fix this by getting the current master (if any), or the saved master (if
temporarily detached due to a grab). And if failing that, use the VCK
as fallback device - that is technically wrong but it's such a niche use
case that it shouldn't matter.

Reproducer:
     window = XCreateSimpleWindow(...)
     deviceid = any device that is IsXExtensionKeyboard device
     XSetDeviceFocus(deviceid, FollowKeyboard, ...)
     XGrabDevice(deviceid, window, ...)

Fixes: f01ee198 ("dix: don't use inputInfo.keyboard to get the focus window in ActivateKbdGrab")

Found-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
Tested-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
Part-of: <!1870>
parent 4966fbb5
Loading
Pipeline #1389051 failed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment