From Melchoir Franz, Caps lock support under X11

This commit is contained in:
Robert Osfield 2008-03-13 16:12:46 +00:00
parent f1fe11f5a9
commit a460d66533
2 changed files with 13 additions and 4 deletions

View File

@ -45,7 +45,8 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
_initialized(false),
_realized(false),
_timeOfLastCheckEvents(-1.0),
_lastEventType(0)
_lastEventType(0),
_lockMask(0)
{
_traits = traits;
memset(_keyMap, 0, 32);
@ -183,6 +184,7 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
double _timeOfLastCheckEvents;
int _lastEventType;
int _lockMask;
char _keyMap[32];
std::map<MouseCursor,Cursor> _mouseCursorMap;

View File

@ -711,7 +711,7 @@ bool GraphicsWindowX11::createWindow()
XSelectInput( _eventDisplay, _window, ExposureMask | StructureNotifyMask |
KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
KeymapStateMask | FocusChangeMask );
KeymapStateMask | FocusChangeMask | EnterWindowMask );
XFlush( _eventDisplay );
XSync( _eventDisplay, 0 );
@ -1015,6 +1015,11 @@ void GraphicsWindowX11::checkEvents()
break;
}
case EnterNotify :
osg::notify(osg::INFO)<<"EnterNotify event received"<<std::endl;
_lockMask = ev.xcrossing.state & LockMask;
break;
case KeymapNotify :
{
osg::notify(osg::INFO)<<"KeymapNotify event received"<<std::endl;
@ -1170,6 +1175,7 @@ void GraphicsWindowX11::checkEvents()
Time relativeTime = ev.xmotion.time - firstEventTime;
eventTime = baseTime + static_cast<double>(relativeTime)*0.001;
_lockMask = ev.xkey.state & LockMask;
keyMapSetKey(_keyMap, ev.xkey.keycode);
int keySymbol = 0;
adaptKey(ev.xkey, keySymbol);
@ -1199,7 +1205,8 @@ void GraphicsWindowX11::checkEvents()
break;
}
}
#endif
#endif
_lockMask = ev.xkey.state & LockMask;
keyMapClearKey(_keyMap, ev.xkey.keycode);
int keySymbol = 0;
adaptKey(ev.xkey, keySymbol);
@ -1312,7 +1319,7 @@ void GraphicsWindowX11::forceKey(int key, double time, bool state)
event.y = 0;
event.x_root = 0;
event.y_root = 0;
event.state = getModifierMask();
event.state = getModifierMask() | _lockMask;
event.keycode = key;
event.same_screen = True;