From 45bd3802de32434f3def2706742b24acd9027e9a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 14 Mar 2008 15:13:08 +0000 Subject: [PATCH] From Melchior Franz, "Attached is a fix for remaining problems in capslock handling: It sets osgGA's keymask when restoring keys on FocusIn, according to the state values of XKeyEvent and XCrossingEvent. (These are the only source for X11's current capslock state that avoids pulling in the XKB extension.) " --- include/osgViewer/api/X11/GraphicsWindowX11 | 1 + src/osgViewer/GraphicsWindowX11.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/osgViewer/api/X11/GraphicsWindowX11 b/include/osgViewer/api/X11/GraphicsWindowX11 index f226300e403..6c3e69555a6 100644 --- a/include/osgViewer/api/X11/GraphicsWindowX11 +++ b/include/osgViewer/api/X11/GraphicsWindowX11 @@ -166,6 +166,7 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow void forceKey(int key, double time, bool state); void getModifierMap(char* keymap) const; int getModifierMask() const; + void syncCapsLock(); bool _valid; Display* _display; diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index 11bd12c485f..46e418874dd 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -1018,6 +1018,7 @@ void GraphicsWindowX11::checkEvents() case EnterNotify : osg::notify(osg::INFO)<<"EnterNotify event received"<getCurrentEventState()->getModKeyMask(); + if (_lockMask) + { + mask |= osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK; + } + else + { + mask &= ~osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK; + } + getEventQueue()->getCurrentEventState()->setModKeyMask(mask); +} + // Returns char[32] keymap with bits for every modifier key set. void GraphicsWindowX11::getModifierMap(char* keymap) const {