Merge branch 'bug-116-autotype-new' into bug-116-autotype

This commit is contained in:
Albert Weichselbraun 2013-11-17 21:10:29 +01:00
commit 6b33298a6e
2 changed files with 37 additions and 33 deletions

View File

@ -615,43 +615,45 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
int revert_to;
XKeyEvent event;
int keycode;
int phase, inx;
int phase;
bool found;
KeySym ks;
unsigned int mods_rtrn = 0;
XkbDescPtr kbd = XkbGetKeyboard (m_dpy, XkbCompatMapMask | XkbGeometryMask, XkbUseCoreKbd);
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
found = FALSE;
keycode = 0;
if (keysym != NoSymbol) {
for (phase = 0; phase < 2; phase++) {
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
/* Determine keycode for the keysym: we use this instead
of XKeysymToKeycode() because we must know shift_state, too */
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
if (m_keysymTable[inx] == keysym) {
keycode = XKeysymToKeycode(m_dpy, keysym);
XkbTranslateKeyCode(kbd, keycode, 0, &mods_rtrn, &ks);
if (ks == keysym) {
shift &= ~m_altgrMask;
if (m_keysymTable[inx + 1] != NoSymbol) shift &= ~ShiftMask;
found = TRUE;
break;
} else if (m_keysymTable[inx + 1] == keysym) {
} else {
XkbTranslateKeyCode(kbd, keycode, ShiftMask, &mods_rtrn, &ks);
if (ks == keysym) {
shift &= ~m_altgrMask;
shift |= ShiftMask;
found = TRUE;
break;
}
}
if (!found && m_altgrMask && inx_altgr + 1 <= m_keysymPerKeycode) {
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
if (m_keysymTable[inx + inx_altgr] == keysym) {
} else {
XkbTranslateKeyCode(kbd, keycode, Mod5Mask, &mods_rtrn, &ks);
if (ks == keysym) {
shift &= ~ShiftMask;
shift |= m_altgrMask;
found = TRUE;
break;
} else if (inx_altgr + 2 <= m_keysymPerKeycode && m_keysymTable[inx + inx_altgr + 1] == keysym) {
} else {
XkbTranslateKeyCode(kbd, keycode, Mod5Mask, &mods_rtrn, &ks);
if (ks == keysym) {
shift |= ShiftMask | m_altgrMask;
found = TRUE;
break;
}
}
}
}
@ -781,6 +783,7 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
SendEvent(&event);
event.state &= ~ControlMask;
}
XkbFreeKeyboard(kbd, XkbAllComponentsMask, True);
}
int AutoTypePlatformX11::MyErrorHandler(Display* my_dpy, XErrorEvent* event)

View File

@ -26,6 +26,7 @@
#include <QX11Info>
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XTest.h>
#include "autotype/AutoTypePlatformPlugin.h"