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:
parent
9f157e61a9
commit
7b8c699448
|
@ -19,18 +19,26 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Application_X11.h"
|
#include "Application_X11.h"
|
||||||
#include "lib/AutoType.h"
|
#include "lib/AutoTypeGlobalX11.h"
|
||||||
#include "lib/HelperX11.h"
|
#include "lib/HelperX11.h"
|
||||||
|
|
||||||
const unsigned int KeepassApplication::remove_invalid = ControlMask|ShiftMask|Mod1Mask|Mod5Mask|Mod4Mask;
|
KeepassApplication::KeepassApplication(int& argc, char** argv) : QApplication(argc, argv), remove_invalid(0){
|
||||||
|
|
||||||
KeepassApplication::KeepassApplication(int& argc, char** argv) : QApplication(argc, argv){
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeepassApplication::x11EventFilter(XEvent* event){
|
bool KeepassApplication::x11EventFilter(XEvent* event){
|
||||||
|
if (autoType == NULL)
|
||||||
|
return QApplication::x11EventFilter(event);
|
||||||
|
|
||||||
|
if (remove_invalid == 0) {
|
||||||
|
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
|
||||||
|
remove_invalid = ControlMask | ShiftMask | autoTypeGlobal->maskAlt() |
|
||||||
|
autoTypeGlobal->maskAltGr() | autoTypeGlobal->maskMeta();
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type==KeyPress && autoType->getShortcut().key!=0u &&
|
if (event->type==KeyPress && autoType->getShortcut().key!=0u &&
|
||||||
event->xkey.keycode == XKeysymToKeycode(event->xkey.display,HelperX11::getKeysym(autoType->getShortcut().key)) &&
|
event->xkey.keycode == XKeysymToKeycode(event->xkey.display,HelperX11::getKeysym(autoType->getShortcut().key)) &&
|
||||||
(event->xkey.state&remove_invalid)==HelperX11::getShortcutModifierMask(autoType->getShortcut()) && focusWidget()==NULL )
|
(event->xkey.state&remove_invalid) == HelperX11::getShortcutModifierMask(autoType->getShortcut()) &&
|
||||||
|
focusWidget()==NULL)
|
||||||
{
|
{
|
||||||
EventOccurred = true;
|
EventOccurred = true;
|
||||||
autoType->performGlobal();
|
autoType->performGlobal();
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef APPLICATION_X11_H
|
#ifndef APPLICATION_X11_H
|
||||||
#define APPLICATION_X11_H
|
#define APPLICATION_X11_H
|
||||||
|
|
||||||
|
|
||||||
class KeepassApplication : public QApplication
|
class KeepassApplication : public QApplication
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -30,7 +29,7 @@ class KeepassApplication : public QApplication
|
||||||
bool x11EventFilter(XEvent* event);
|
bool x11EventFilter(XEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const unsigned int remove_invalid;
|
unsigned int remove_invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPLICATION_X11_H
|
#endif // APPLICATION_X11_H
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define APP_CODE_NAME "keepassx"
|
#define APP_CODE_NAME "keepassx"
|
||||||
#define APP_SHORT_FUNC "Password Manager"
|
#define APP_SHORT_FUNC "Password Manager"
|
||||||
#define APP_LONG_FUNC "Cross Platform Password Manager"
|
#define APP_LONG_FUNC "Cross Platform Password Manager"
|
||||||
#define APP_VERSION "0.4.0b"
|
#define APP_VERSION "0.4.0beta1"
|
||||||
|
|
||||||
#define BUILTIN_ICONS 69
|
#define BUILTIN_ICONS 69
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ class AutoTypeGlobalX11 : public AutoTypeX11, public AutoTypeGlobal {
|
||||||
bool registerGlobalShortcut(const Shortcut& s);
|
bool registerGlobalShortcut(const Shortcut& s);
|
||||||
void unregisterGlobalShortcut();
|
void unregisterGlobalShortcut();
|
||||||
QStringList getAllWindowTitles();
|
QStringList getAllWindowTitles();
|
||||||
|
inline int maskAlt() { return alt_mask; };
|
||||||
|
inline int maskAltGr() { return altgr_mask; };
|
||||||
|
inline int maskMeta() { return meta_mask; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void windowTitles(Window window, QStringList& titleList);
|
void windowTitles(Window window, QStringList& titleList);
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool AutoTypeX11::error_detected = false;
|
||||||
|
|
||||||
AutoTypeX11::AutoTypeX11(KeepassMainWindow* mainWin) {
|
AutoTypeX11::AutoTypeX11(KeepassMainWindow* mainWin) {
|
||||||
this->mainWin = mainWin;
|
this->mainWin = mainWin;
|
||||||
dpy = mainWin->x11Info().display();
|
dpy = QX11Info::display();
|
||||||
|
|
||||||
keysym_table = NULL;
|
keysym_table = NULL;
|
||||||
alt_mask = 0;
|
alt_mask = 0;
|
||||||
|
|
|
@ -22,13 +22,18 @@
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
|
||||||
#ifdef GLOBAL_AUTOTYPE
|
#ifdef GLOBAL_AUTOTYPE
|
||||||
|
#include "AutoTypeGlobalX11.h"
|
||||||
|
|
||||||
int HelperX11::getShortcutModifierMask(const Shortcut& s){
|
int HelperX11::getShortcutModifierMask(const Shortcut& s){
|
||||||
|
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
|
||||||
|
|
||||||
int mod = 0;
|
int mod = 0;
|
||||||
if (s.ctrl) mod |= ControlMask;
|
if (s.ctrl) mod |= ControlMask;
|
||||||
if (s.shift) mod |= ShiftMask;
|
if (s.shift) mod |= ShiftMask;
|
||||||
if (s.alt) mod |= Mod1Mask;
|
if (s.alt) mod |= autoTypeGlobal->maskAlt();
|
||||||
if (s.altgr) mod |= Mod5Mask;
|
if (s.altgr) mod |= autoTypeGlobal->maskAltGr();
|
||||||
if (s.win) mod |= Mod4Mask;
|
if (s.win) mod |= autoTypeGlobal->maskMeta();
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,8 +72,8 @@ int (*HelperX11::oldHandler) (Display*, XErrorEvent*) = NULL;
|
||||||
bool HelperX11::catchErrors = false;
|
bool HelperX11::catchErrors = false;
|
||||||
bool HelperX11::pErrorOccurred = false;
|
bool HelperX11::pErrorOccurred = false;
|
||||||
|
|
||||||
XID HelperX11::getKeysym(const QChar& c){
|
KeySym HelperX11::getKeysym(const QChar& c){
|
||||||
KeySym unicode = c.unicode();
|
ushort unicode = c.unicode();
|
||||||
|
|
||||||
/* first check for Latin-1 characters (1:1 mapping) */
|
/* first check for Latin-1 characters (1:1 mapping) */
|
||||||
if ((unicode >= 0x0020 && unicode <= 0x007e) ||
|
if ((unicode >= 0x0020 && unicode <= 0x007e) ||
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
#ifndef HELPERX11_H
|
#ifndef HELPERX11_H
|
||||||
#define HELPERX11_H
|
#define HELPERX11_H
|
||||||
|
|
||||||
#include "AutoType.h"
|
|
||||||
#include <QChar>
|
|
||||||
|
|
||||||
#define XK_MISCELLANY
|
#define XK_MISCELLANY
|
||||||
#define XK_XKB_KEYS
|
#define XK_XKB_KEYS
|
||||||
#define XK_3270
|
#define XK_3270
|
||||||
#define XK_CURRENCY
|
#define XK_CURRENCY
|
||||||
|
|
||||||
|
#include "AutoType.h"
|
||||||
|
#include <QChar>
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#include <X11/keysymdef.h>
|
#include <X11/keysymdef.h>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include "HelperX11.h"
|
#include "HelperX11.h"
|
||||||
|
#include "AutoTypeGlobalX11.h"
|
||||||
|
|
||||||
ShortcutWidget::ShortcutWidget(QWidget* parent) : QLineEdit(parent), lock(false), failed(false){
|
ShortcutWidget::ShortcutWidget(QWidget* parent) : QLineEdit(parent), lock(false), failed(false){
|
||||||
}
|
}
|
||||||
|
@ -55,8 +56,12 @@ void ShortcutWidget::keyEvent(QKeyEvent* event, bool release){
|
||||||
if (release && lock)
|
if (release && lock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
|
||||||
|
|
||||||
unsigned int mods = HelperX11::keyboardModifiers(QX11Info::display());
|
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){
|
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(" + ");
|
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) ){
|
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);
|
KeySym keysym = XKeycodeToKeysym(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),key), 0);
|
||||||
if (keysym>=0xfd00 && keysym<=0xffff){
|
if (keysym>=0xfd00 && keysym<=0xffff){
|
||||||
text.append(XKeysymToString(keysym));
|
text.append(XKeysymToString(keysym));
|
||||||
|
|
|
@ -17,6 +17,10 @@ else {
|
||||||
CONFIG += release
|
CONFIG += release
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEqual(NOSTRIP,1) {
|
||||||
|
CONFIG += nostrip
|
||||||
|
}
|
||||||
|
|
||||||
# lipo and freebsd cannot handle precompiled headers (yet)
|
# lipo and freebsd cannot handle precompiled headers (yet)
|
||||||
!isEqual(PRECOMPILED,1){
|
!isEqual(PRECOMPILED,1){
|
||||||
macx : isEqual(ARCH,UNIVERSAL) : PRECOMPILED = 0
|
macx : isEqual(ARCH,UNIVERSAL) : PRECOMPILED = 0
|
||||||
|
|
Loading…
Reference in New Issue