From 86146f54d5641807d50591949a40cc24ca59d676 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Fri, 9 May 2014 00:26:51 +0200 Subject: [PATCH] [X11] Fixed key repeat --- Source/OpenTK/Platform/X11/X11GLNative.cs | 52 +---------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index 017e0206..22bb8515 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -865,40 +865,8 @@ namespace OpenTK.Platform.X11 { if (pressed) { - // Check if this is a key repeat event. - // X11 does not provide this information, - // so we rely on the XInput2 extension for that. - // Todo: hack this when XInput2 is not available - // by checking if another KeyPress event is enqueued. - bool is_repeat = false; - if (xi2_supported && e.GenericEventCookie.extension == xi2_opcode) - { - if (e.GenericEventCookie.evtype == (int)XIEventType.KeyPress) - { - unsafe - { - XIDeviceEvent* xi = (XIDeviceEvent*)e.GenericEventCookie.data; - is_repeat = (xi->flags & XIEventFlags.KeyRepeat) != 0; - } - } - } - else - { - if (API.Pending(window.Display) > 0) - { - unsafe - { - XEvent dummy = new XEvent(); - KeyRepeatTestData arg = new KeyRepeatTestData(); - arg.Event = e; - API.CheckIfEvent(window.Display, ref dummy, IsKeyRepeatPredicate, - new IntPtr(&arg)); - is_repeat = arg.IsRepeat; - } - } - } - // Raise KeyDown event + bool is_repeat = KeyboardState[key]; OnKeyDown(key, is_repeat); } else @@ -1060,24 +1028,6 @@ namespace OpenTK.Platform.X11 } } - struct KeyRepeatTestData - { - public XEvent Event; - public bool IsRepeat; - } - - unsafe static bool IsKeyRepeatPredicate(IntPtr display, ref XEvent e, IntPtr arg) - { - // IsRepeat is true when the event queue contains an identical - // KeyPress event at later time no greater than 2. - KeyRepeatTestData* data = (KeyRepeatTestData*)arg; - data->IsRepeat = - e.type == XEventName.KeyPress && - e.KeyEvent.keycode == data->Event.KeyEvent.keycode && - e.KeyEvent.time.ToInt64() - data->Event.KeyEvent.time.ToInt64() < 2; - return false; // keep the event in the queue - } - #endregion #region Bounds