Dynamically calculate modifier value of alt, altgr and meta/win
Added nostrip qmake option git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@246 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -31,6 +31,9 @@ class AutoTypeGlobalX11 : public AutoTypeX11, public AutoTypeGlobal {
|
||||
bool registerGlobalShortcut(const Shortcut& s);
|
||||
void unregisterGlobalShortcut();
|
||||
QStringList getAllWindowTitles();
|
||||
inline int maskAlt() { return alt_mask; };
|
||||
inline int maskAltGr() { return altgr_mask; };
|
||||
inline int maskMeta() { return meta_mask; };
|
||||
|
||||
private:
|
||||
void windowTitles(Window window, QStringList& titleList);
|
||||
|
||||
@@ -39,7 +39,7 @@ bool AutoTypeX11::error_detected = false;
|
||||
|
||||
AutoTypeX11::AutoTypeX11(KeepassMainWindow* mainWin) {
|
||||
this->mainWin = mainWin;
|
||||
dpy = mainWin->x11Info().display();
|
||||
dpy = QX11Info::display();
|
||||
|
||||
keysym_table = NULL;
|
||||
alt_mask = 0;
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
#include <QX11Info>
|
||||
|
||||
#ifdef GLOBAL_AUTOTYPE
|
||||
#include "AutoTypeGlobalX11.h"
|
||||
|
||||
int HelperX11::getShortcutModifierMask(const Shortcut& s){
|
||||
int mod=0;
|
||||
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
|
||||
|
||||
int mod = 0;
|
||||
if (s.ctrl) mod |= ControlMask;
|
||||
if (s.shift) mod |= ShiftMask;
|
||||
if (s.alt) mod |= Mod1Mask;
|
||||
if (s.altgr) mod |= Mod5Mask;
|
||||
if (s.win) mod |= Mod4Mask;
|
||||
if (s.alt) mod |= autoTypeGlobal->maskAlt();
|
||||
if (s.altgr) mod |= autoTypeGlobal->maskAltGr();
|
||||
if (s.win) mod |= autoTypeGlobal->maskMeta();
|
||||
|
||||
return mod;
|
||||
}
|
||||
#endif
|
||||
@@ -67,8 +72,8 @@ int (*HelperX11::oldHandler) (Display*, XErrorEvent*) = NULL;
|
||||
bool HelperX11::catchErrors = false;
|
||||
bool HelperX11::pErrorOccurred = false;
|
||||
|
||||
XID HelperX11::getKeysym(const QChar& c){
|
||||
KeySym unicode = c.unicode();
|
||||
KeySym HelperX11::getKeysym(const QChar& c){
|
||||
ushort unicode = c.unicode();
|
||||
|
||||
/* first check for Latin-1 characters (1:1 mapping) */
|
||||
if ((unicode >= 0x0020 && unicode <= 0x007e) ||
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#ifndef HELPERX11_H
|
||||
#define HELPERX11_H
|
||||
|
||||
#include "AutoType.h"
|
||||
#include <QChar>
|
||||
|
||||
#define XK_MISCELLANY
|
||||
#define XK_XKB_KEYS
|
||||
#define XK_3270
|
||||
#define XK_CURRENCY
|
||||
|
||||
#include "AutoType.h"
|
||||
#include <QChar>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/keysymdef.h>
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QX11Info>
|
||||
#include <QPalette>
|
||||
#include "HelperX11.h"
|
||||
#include "AutoTypeGlobalX11.h"
|
||||
|
||||
ShortcutWidget::ShortcutWidget(QWidget* parent) : QLineEdit(parent), lock(false), failed(false){
|
||||
}
|
||||
@@ -55,8 +56,12 @@ void ShortcutWidget::keyEvent(QKeyEvent* event, bool release){
|
||||
if (release && lock)
|
||||
return;
|
||||
|
||||
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
|
||||
|
||||
unsigned int mods = HelperX11::keyboardModifiers(QX11Info::display());
|
||||
displayShortcut(event->nativeVirtualKey(), release, mods&ControlMask, mods&ShiftMask, mods&Mod1Mask, mods&Mod5Mask, mods&Mod4Mask);
|
||||
displayShortcut(event->nativeVirtualKey(), release, mods & ControlMask,
|
||||
mods & ShiftMask, mods & autoTypeGlobal->maskAlt(),
|
||||
mods & autoTypeGlobal->maskAltGr(), mods & autoTypeGlobal->maskMeta());
|
||||
}
|
||||
|
||||
void ShortcutWidget::displayShortcut(quint32 key, bool release, bool ctrl, bool shift, bool alt, bool altgr, bool win){
|
||||
@@ -74,6 +79,7 @@ void ShortcutWidget::displayShortcut(quint32 key, bool release, bool ctrl, bool
|
||||
text.append(tr("Win")).append(" + ");
|
||||
|
||||
if ( !release && (key<XK_Shift_L || key>XK_Hyper_R) && (key<XK_ISO_Lock || key>XK_ISO_Last_Group_Lock) ){
|
||||
// converts key into orignal key on the keyboard
|
||||
KeySym keysym = XKeycodeToKeysym(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),key), 0);
|
||||
if (keysym>=0xfd00 && keysym<=0xffff){
|
||||
text.append(XKeysymToString(keysym));
|
||||
|
||||
Reference in New Issue
Block a user