There's a problem with the keyboard support on X11. It's really
caused by the way X works, and SDL or glut are said to struggle
with it as well. I haven't seen the problem there, though, so
they probably found a way to work around it.

To reproduce start the osgkeyboard example, press a few modifier
keys (let's say Ctrl and Shift) and while keeping them pressed
switch the desktop (e.g. on KDE) or minimize the window. Release
the modifier keys. Now, when you switch back or open the minimized
window, you'll see Ctrl and Shift still activated. And it's not
only an visual problem. These keys are actually not released, and
pressing 'a' will now really be seen as 'A'. That's very annoying
in FlightGear. One has to press and release the respective modifier
keys to get the missing release event.

I've "fixed" that here with a little hack. I doubt that it's
acceptable for CVS, as it sends releases for keys that were never
pressed, which might confuse some applications. But maybe the patch
inspires someone to write a real fix. ("UnmapNotify" is sent when
the window gets hidden away, and "MapNotify" when it's brought back.)

m.



Index: src/osgViewer/GraphicsWindowX11.cpp
===================================================================
--- src/osgViewer/GraphicsWindowX11.cpp (revision 7855)
+++ src/osgViewer/GraphicsWindowX11.cpp (working copy)
@@ -919,6 +919,14 @@

             case UnmapNotify :
                 osg::notify(osg::INFO)<<"UnmapNotify event 
recieved"<<std::endl;
+#define RELEASE(a) getEventQueue()->keyRelease(osgGA::GUIEventAdapter::a, 
eventTime)
+                RELEASE(KEY_Shift_L),   RELEASE(KEY_Shift_R);
+                RELEASE(KEY_Control_L), RELEASE(KEY_Control_R);
+                RELEASE(KEY_Meta_L),    RELEASE(KEY_Meta_R);
+                RELEASE(KEY_Alt_L),     RELEASE(KEY_Alt_R);
+                RELEASE(KEY_Super_L),   RELEASE(KEY_Super_R);
+                RELEASE(KEY_Hyper_L),   RELEASE(KEY_Hyper_R);
+#undef RELEASE
                 break;

             case ReparentNotify:
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to