Skip to content

Commit

Permalink
From Melchior Franz, "Attached is a fix for remaining problems in cap…
Browse files Browse the repository at this point in the history
…slock 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.)
"
  • Loading branch information
robertosfield committed Mar 14, 2008
1 parent dbd4bdc commit 45bd380
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/osgViewer/api/X11/GraphicsWindowX11
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/osgViewer/GraphicsWindowX11.cpp
Expand Up @@ -1018,6 +1018,7 @@ void GraphicsWindowX11::checkEvents()
case EnterNotify :
osg::notify(osg::INFO)<<"EnterNotify event received"<<std::endl;
_lockMask = ev.xcrossing.state & LockMask;
syncCapsLock();
break;

case KeymapNotify :
Expand All @@ -1030,6 +1031,7 @@ void GraphicsWindowX11::checkEvents()

char modMap[32];
getModifierMap(modMap);
syncCapsLock();

// release normal (non-modifier) keys
for (unsigned int key = 8; key < 256; key++)
Expand Down Expand Up @@ -1340,6 +1342,20 @@ void GraphicsWindowX11::forceKey(int key, double time, bool state)
}
}

void GraphicsWindowX11::syncCapsLock()
{
unsigned int mask = getEventQueue()->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
{
Expand Down

0 comments on commit 45bd380

Please sign in to comment.