mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-30 09:46:30 -05:00
Merge branch 'bug-116-autotype-new' into bug-116-autotype
This commit is contained in:
commit
6b33298a6e
@ -615,54 +615,56 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
|
|||||||
int revert_to;
|
int revert_to;
|
||||||
XKeyEvent event;
|
XKeyEvent event;
|
||||||
int keycode;
|
int keycode;
|
||||||
int phase, inx;
|
int phase;
|
||||||
bool found;
|
bool found;
|
||||||
|
KeySym ks;
|
||||||
|
unsigned int mods_rtrn = 0;
|
||||||
|
XkbDescPtr kbd = XkbGetKeyboard (m_dpy, XkbCompatMapMask | XkbGeometryMask, XkbUseCoreKbd);
|
||||||
|
|
||||||
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
|
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
|
||||||
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
keycode = 0;
|
keycode = 0;
|
||||||
|
|
||||||
if (keysym != NoSymbol) {
|
if (keysym != NoSymbol) {
|
||||||
for (phase = 0; phase < 2; phase++) {
|
for (phase = 0; phase < 2; phase++) {
|
||||||
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
|
keycode = XKeysymToKeycode(m_dpy, keysym);
|
||||||
/* Determine keycode for the keysym: we use this instead
|
XkbTranslateKeyCode(kbd, keycode, 0, &mods_rtrn, &ks);
|
||||||
of XKeysymToKeycode() because we must know shift_state, too */
|
if (ks == keysym) {
|
||||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
shift &= ~m_altgrMask;
|
||||||
if (m_keysymTable[inx] == keysym) {
|
found = TRUE;
|
||||||
shift &= ~m_altgrMask;
|
} else {
|
||||||
if (m_keysymTable[inx + 1] != NoSymbol) shift &= ~ShiftMask;
|
|
||||||
found = TRUE;
|
XkbTranslateKeyCode(kbd, keycode, ShiftMask, &mods_rtrn, &ks);
|
||||||
break;
|
if (ks == keysym) {
|
||||||
} else if (m_keysymTable[inx + 1] == keysym) {
|
shift &= ~m_altgrMask;
|
||||||
shift &= ~m_altgrMask;
|
shift |= ShiftMask;
|
||||||
shift |= ShiftMask;
|
found = TRUE;
|
||||||
found = TRUE;
|
} else {
|
||||||
break;
|
|
||||||
}
|
XkbTranslateKeyCode(kbd, keycode, Mod5Mask, &mods_rtrn, &ks);
|
||||||
}
|
if (ks == keysym) {
|
||||||
if (!found && m_altgrMask && inx_altgr + 1 <= m_keysymPerKeycode) {
|
shift &= ~ShiftMask;
|
||||||
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
|
shift |= m_altgrMask;
|
||||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
found = TRUE;
|
||||||
if (m_keysymTable[inx + inx_altgr] == keysym) {
|
} else {
|
||||||
shift &= ~ShiftMask;
|
|
||||||
shift |= m_altgrMask;
|
XkbTranslateKeyCode(kbd, keycode, Mod5Mask, &mods_rtrn, &ks);
|
||||||
found = TRUE;
|
if (ks == keysym) {
|
||||||
break;
|
shift |= ShiftMask | m_altgrMask;
|
||||||
} else if (inx_altgr + 2 <= m_keysymPerKeycode && m_keysymTable[inx + inx_altgr + 1] == keysym) {
|
found = TRUE;
|
||||||
shift |= ShiftMask | m_altgrMask;
|
}
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) break;
|
if (found) break;
|
||||||
|
|
||||||
if (0xF000 <= keysym) {
|
if (0xF000 <= keysym) {
|
||||||
/* for special keys such as function keys,
|
/* for special keys such as function keys,
|
||||||
first try to add it in the non-shifted position of the keymap */
|
first try to add it in the non-shifted position of the keymap */
|
||||||
if (AddKeysym(keysym, TRUE) == NoSymbol) AddKeysym(keysym, FALSE);
|
if (AddKeysym(keysym, TRUE) == NoSymbol) AddKeysym(keysym, FALSE);
|
||||||
} else {
|
} else {
|
||||||
AddKeysym(keysym, FALSE);
|
AddKeysym(keysym, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,6 +783,7 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
|
|||||||
SendEvent(&event);
|
SendEvent(&event);
|
||||||
event.state &= ~ControlMask;
|
event.state &= ~ControlMask;
|
||||||
}
|
}
|
||||||
|
XkbFreeKeyboard(kbd, XkbAllComponentsMask, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AutoTypePlatformX11::MyErrorHandler(Display* my_dpy, XErrorEvent* event)
|
int AutoTypePlatformX11::MyErrorHandler(Display* my_dpy, XErrorEvent* event)
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
|
|
||||||
#include "autotype/AutoTypePlatformPlugin.h"
|
#include "autotype/AutoTypePlatformPlugin.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user