mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-28 15:27:18 -05:00
Track the last remapped keysym in m_currentRemapKeycode to enforce
a new computation of m_remapKeycode when the keyboard layout changes. (This fixes a potential problem with AddKeysym overwriting used keysyms after applying a new keyboard layout).
This commit is contained in:
parent
1fce1ac905
commit
6a50a76466
@ -46,7 +46,8 @@ AutoTypePlatformX11::AutoTypePlatformX11()
|
||||
|
||||
m_keysymTable = Q_NULLPTR;
|
||||
m_xkb = Q_NULLPTR;
|
||||
m_specialCharacterKeycode = 0;
|
||||
m_remapKeycode = 0;
|
||||
m_currentRemapKeycode = NoSymbol;
|
||||
m_modifierMask = ControlMask | ShiftMask | Mod1Mask | Mod4Mask;
|
||||
|
||||
m_loaded = true;
|
||||
@ -440,11 +441,12 @@ void AutoTypePlatformX11::updateKeymap()
|
||||
&m_keysymPerKeycode);
|
||||
|
||||
/* determine the keycode to use for remapped keys */
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
inx = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_remapKeycode == 0 || m_keysymTable[inx] != m_currentRemapKeycode) {
|
||||
for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) {
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx] == NoSymbol) {
|
||||
m_specialCharacterKeycode = keycode;
|
||||
m_remapKeycode = keycode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -505,13 +507,13 @@ int AutoTypePlatformX11::x11ErrorHandler(Display* display, XErrorEvent* error)
|
||||
*/
|
||||
int AutoTypePlatformX11::AddKeysym(KeySym keysym)
|
||||
{
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
if (m_remapKeycode == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inx = (m_specialCharacterKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
int inx = (m_remapKeycode- m_minKeycode) * m_keysymPerKeycode;
|
||||
m_keysymTable[inx] = keysym;
|
||||
XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
XChangeKeyboardMapping(m_dpy, m_remapKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
XFlush(m_dpy);
|
||||
|
||||
/* Xlib needs some time until the mapping is distributed to
|
||||
@ -521,7 +523,7 @@ int AutoTypePlatformX11::AddKeysym(KeySym keysym)
|
||||
ts.tv_nsec = 10 * 1000 * 1000;
|
||||
nanosleep(&ts, Q_NULLPTR);
|
||||
|
||||
return m_specialCharacterKeycode;
|
||||
return m_remapKeycode;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -106,8 +106,9 @@ private:
|
||||
int m_minKeycode;
|
||||
int m_maxKeycode;
|
||||
int m_keysymPerKeycode;
|
||||
/* dedicated 'special character' keycode */
|
||||
int m_specialCharacterKeycode;
|
||||
/* dedicated keycode for remapped keys */
|
||||
unsigned int m_remapKeycode;
|
||||
KeySym m_currentRemapKeycode;
|
||||
KeyCode m_modifier_keycode[N_MOD_INDICES];
|
||||
bool m_loaded;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user