From 9e6c3a76283bb1045d51b705a798bc5cd25b38a8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 8 May 2008 16:45:59 +0000 Subject: [PATCH] From Melchior Franz, "In KDE I switch desktops with Super-Tab, and occasionally I get an excess Tab key report when switching back to an OSG application (usually FlightGear :-). Although KDE has consumed the Tab, it's sometimes still in the XKeymapEvent's key_vector, and followed by a Tab KeyRelease event. Avoid this artifact by - asking for a "fresh" keymap (via XQueryKeymap()), rather than using the unreliable(?) XKeymapEvent's key_vector, and by - flushing all key events on focus-in (to avoid the KeyRelease) After Super-press, Tab-press, Super-release, Tab-release (note the wrong release order!) I still get an extra Tab event. But this is not surprising and not exactly wrong either. Also it's hard to avoid, as we can't see what happened to the keyboard before we regained focus. Files changed: src/osgViewer/GraphicsWindowX11.cpp include/osgViewer/api/X11/GraphicsWindowX11" --- include/osgViewer/api/X11/GraphicsWindowX11 | 1 + src/osgViewer/GraphicsWindowX11.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/osgViewer/api/X11/GraphicsWindowX11 b/include/osgViewer/api/X11/GraphicsWindowX11 index c4015af86..6f5436567 100644 --- a/include/osgViewer/api/X11/GraphicsWindowX11 +++ b/include/osgViewer/api/X11/GraphicsWindowX11 @@ -169,6 +169,7 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow void getModifierMap(char* keymap) const; int getModifierMask() const; void syncLocks(); + void flushKeyEvents(); bool _valid; Display* _display; diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index 513b68214..73d10b550 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -993,6 +993,7 @@ void GraphicsWindowX11::checkEvents() case FocusIn : osg::notify(osg::INFO)<<"FocusIn event received"<