Merge pull request #11758 from jbosboom/xinput2-client-pointer

XInput2: Accept input from keyboards other than the first master
This commit is contained in:
Admiral H. Curtiss 2023-05-19 19:29:24 +02:00 committed by GitHub
commit 279fcafdc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -166,6 +166,10 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
name = std::string(pointer_device->name);
XIFreeDeviceInfo(pointer_device);
// Tell core X functions which keyboard is "the" keyboard for this
// X connection.
XISetClientPointer(m_display, None, pointer_deviceid);
{
unsigned char mask_buf[(XI_LASTEVENT + 7) / 8] = {};
XISetMask(mask_buf, XI_ButtonPress);
@ -387,6 +391,10 @@ void KeyboardMouse::UpdateInput()
// KeyRelease and FocusOut events are sometimes not received.
// Cycling Alt-Tab and landing on the same window results in a stuck "Alt" key.
// Unpressed keys are released here.
// Because we called XISetClientPointer in the constructor, XQueryKeymap
// will return the state of the associated keyboard, even if it isn't the
// first master keyboard. (XInput2 doesn't provide a function to query
// keyboard state.)
std::array<char, 32> keyboard;
XQueryKeymap(m_display, keyboard.data());
for (size_t i = 0; i != keyboard.size(); ++i)