Thanks to all who replied. I've now written a cleaner fix.
The focus on modifiers was silly. After we lose all releases
on a "window hide" event, not only modifier releases, we also
have to fake-release all of them. What made the most sense
to me was to maintain a keyStateMap which keeps track of
the pressed/released state. On "UnmapNotify" all pressed
keys are released. (I didn't mess with the current-event-state's
modifier mask, as this is updated with the next event, anyway.)
Patch attached. (I'll submit that if there are no serious
objections.)
m.
Index: src/osgViewer/GraphicsWindowX11.cpp
===================================================================
--- src/osgViewer/GraphicsWindowX11.cpp (revision 7855)
+++ src/osgViewer/GraphicsWindowX11.cpp (working copy)
@@ -918,8 +918,20 @@
break;
case UnmapNotify :
+ {
osg::notify(osg::INFO)<<"UnmapNotify event recieved"<<std::endl;
+ osgGA::EventQueue *eq = getEventQueue();
+ std::map<int,bool>::iterator it, end = _keyStateMap.end();
+ for (it = _keyStateMap.begin(); it != end; ++it)
+ {
+ if (it->second)
+ {
+ eq->keyRelease(it->first, eventTime);
+ it->second = false;
+ }
+ }
break;
+ }
case ReparentNotify:
osg::notify(osg::INFO)<<"ReparentNotify event recieved"<<std::endl;
@@ -1093,6 +1105,7 @@
//getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask);
getEventQueue()->keyPress(keySymbol, eventTime);
+ _keyStateMap[keySymbol] = true;
break;
}
@@ -1124,6 +1137,7 @@
//getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask);
getEventQueue()->keyRelease(keySymbol, eventTime);
+ _keyStateMap[keySymbol] = false;
break;
}
Index: include/osgViewer/api/X11/GraphicsWindowX11
===================================================================
--- include/osgViewer/api/X11/GraphicsWindowX11 (revision 7855)
+++ include/osgViewer/api/X11/GraphicsWindowX11 (working copy)
@@ -179,6 +179,7 @@
double _timeOfLastCheckEvents;
std::map<MouseCursor,Cursor> _mouseCursorMap;
+ std::map<int,bool> _keyStateMap;
};
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org