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
master
sniperbeamer 16 years ago
parent 9f157e61a9
commit 7b8c699448
  1. 20
      src/Application_X11.cpp
  2. 3
      src/Application_X11.h
  3. 2
      src/keepassx.h
  4. 3
      src/lib/AutoTypeGlobalX11.h
  5. 2
      src/lib/AutoTypeX11.cpp
  6. 17
      src/lib/HelperX11.cpp
  7. 6
      src/lib/HelperX11.h
  8. 8
      src/lib/ShortcutWidget.cpp
  9. 4
      src/src.pro

@ -19,18 +19,26 @@
#include "Application_X11.h"
#include "lib/AutoType.h"
#include "lib/AutoTypeGlobalX11.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){
KeepassApplication::KeepassApplication(int& argc, char** argv) : QApplication(argc, argv), remove_invalid(0){
}
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 &&
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.keycode == XKeysymToKeycode(event->xkey.display,HelperX11::getKeysym(autoType->getShortcut().key)) &&
(event->xkey.state&remove_invalid) == HelperX11::getShortcutModifierMask(autoType->getShortcut()) &&
focusWidget()==NULL)
{
EventOccurred = true;
autoType->performGlobal();

@ -20,7 +20,6 @@
#ifndef APPLICATION_X11_H
#define APPLICATION_X11_H
class KeepassApplication : public QApplication
{
Q_OBJECT
@ -30,7 +29,7 @@ class KeepassApplication : public QApplication
bool x11EventFilter(XEvent* event);
private:
static const unsigned int remove_invalid;
unsigned int remove_invalid;
};
#endif // APPLICATION_X11_H

@ -26,7 +26,7 @@
#define APP_CODE_NAME "keepassx"
#define APP_SHORT_FUNC "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

@ -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));

@ -17,6 +17,10 @@ else {
CONFIG += release
}
isEqual(NOSTRIP,1) {
CONFIG += nostrip
}
# lipo and freebsd cannot handle precompiled headers (yet)
!isEqual(PRECOMPILED,1){
macx : isEqual(ARCH,UNIVERSAL) : PRECOMPILED = 0