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.) "
This commit is contained in:
parent
dbd4bdcd89
commit
45bd3802de
@ -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;
|
||||
|
@ -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 :
|
||||
@ -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++)
|
||||
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user