Check all modifiers before declaring the remap keycode invalid.

Sometimes XChangeKeyboardMapping() maps the keysym to a modifier.
This commit is contained in:
Felix Geyer 2014-01-19 21:40:25 +01:00
parent 34b82da9aa
commit bf9a755bea
2 changed files with 15 additions and 1 deletions

View File

@ -442,11 +442,12 @@ void AutoTypePlatformX11::updateKeymap()
/* determine the keycode to use for remapped keys */
inx = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode;
if (m_remapKeycode == 0 || m_keysymTable[inx] != m_currentRemapKeysym) {
if (m_remapKeycode == 0 || !isRemapKeycodeValid()) {
for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) {
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
if (m_keysymTable[inx] == NoSymbol) {
m_remapKeycode = keycode;
m_currentRemapKeysym = NoSymbol;
break;
}
}
@ -467,6 +468,18 @@ void AutoTypePlatformX11::updateKeymap()
XFreeModifiermap(modifiers);
}
bool AutoTypePlatformX11::isRemapKeycodeValid()
{
int baseKeycode = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode;
for (int i = 0; i < m_keysymPerKeycode; i++) {
if (m_keysymTable[baseKeycode + i] == m_currentRemapKeysym) {
return true;
}
}
return false;
}
void AutoTypePlatformX11::startCatchXErrors()
{
Q_ASSERT(!m_catchXErrors);

View File

@ -72,6 +72,7 @@ private:
static int x11ErrorHandler(Display* display, XErrorEvent* error);
void updateKeymap();
bool isRemapKeycodeValid();
int AddKeysym(KeySym keysym);
void AddModifier(KeySym keysym);
void SendEvent(XKeyEvent* event, int event_type);