mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Cleanup of XKB detection code.
This commit is contained in:
@@ -615,6 +615,36 @@ static void processEvent(XEvent *event)
|
||||
const int key = translateKey(event->xkey.keycode);
|
||||
const int mods = translateState(event->xkey.state);
|
||||
|
||||
if (!_glfw.x11.xkb.detectable)
|
||||
{
|
||||
// XKB detectable key repeat is not supported on this server
|
||||
// For key repeats we will get KeyRelease/KeyPress pairs with
|
||||
// similar or identical time stamps. User selected key repeat
|
||||
// filtering is handled in _glfwInputKey/_glfwInputChar.
|
||||
if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
|
||||
{
|
||||
XEvent nextEvent;
|
||||
XPeekEvent(_glfw.x11.display, &nextEvent);
|
||||
|
||||
if (nextEvent.type == KeyPress &&
|
||||
nextEvent.xkey.window == event->xkey.window &&
|
||||
nextEvent.xkey.keycode == event->xkey.keycode)
|
||||
{
|
||||
// This last check is a hack to work around key repeats
|
||||
// leaking through due to some sort of time drift
|
||||
// Toshiyuki Takahashi can press a button 16 times per
|
||||
// second so it's fairly safe to assume that no human is
|
||||
// pressing the key 50 times per second (value is ms)
|
||||
if ((nextEvent.xkey.time - event->xkey.time) < 20)
|
||||
{
|
||||
// This is a server-generated key repeat event
|
||||
// Do not report anything for this event
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_glfwInputKey(window, key, event->xkey.keycode, GLFW_RELEASE, mods);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user