From 175bb58b582cddd8e46efeeda5ee24fec1c65b55 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 5 Aug 2007 14:59:17 +0000 Subject: [PATCH] From Tim More, "This patch causes GraphicsWindowX11 to not send key release events when a key press / release is caused by auto-repeat. This is consistent with Windows and Mac behavior, as well as other toolkits such as SDL." --- src/osgViewer/GraphicsWindowX11.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index d62d7bdab..7c72c82b5 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -976,7 +976,23 @@ void GraphicsWindowX11::checkEvents() if (firstEventTime==0) firstEventTime = ev.xmotion.time; Time relativeTime = ev.xmotion.time - firstEventTime; eventTime = baseTime + static_cast(relativeTime)*0.001; - +#if 1 + // Check for following KeyPress events and see if + // the pair are the result of auto-repeat. If so, drop + // this one on the floor, to be consistent with + // Windows and Mac ports. The idea comes from libSDL sources. + XEvent nextev; + if (XPending(display)) + { + XPeekEvent(display, &nextev); + if ((nextev.type == KeyPress) + && (nextev.xkey.keycode == ev.xkey.keycode) + && (nextev.xmotion.time - ev.xmotion.time < 2)) + { + break; + } + } +#endif int keySymbol = 0; unsigned int modifierMask = 0; adaptKey(ev.xkey, keySymbol, modifierMask);