Skip to content

Commit

Permalink
Cleanup QxtGlobalShortcut a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
trollixx committed May 4, 2015
1 parent 2a7834a commit 9a77d12
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/3rdparty/qxtglobalshortcut/qxtglobalshortcut_mac.cpp
Expand Up @@ -32,7 +32,6 @@
#include "qxtglobalshortcut_p.h"
#include <QMap>
#include <QHash>
#include <QtDebug>
#include <QApplication>

typedef QPair<uint, uint> Identifier;
Expand Down
1 change: 0 additions & 1 deletion src/3rdparty/qxtglobalshortcut/qxtglobalshortcut_p.h
Expand Up @@ -53,7 +53,6 @@ class QxtGlobalShortcutPrivate : public QAbstractNativeEventFilter
bool setShortcut(const QKeySequence &shortcut);
bool unsetShortcut();

static bool error;
#ifndef Q_OS_OSX
static int ref;
#endif // Q_OS_OSX
Expand Down
46 changes: 23 additions & 23 deletions src/3rdparty/qxtglobalshortcut/qxtglobalshortcut_x11.cpp
Expand Up @@ -145,30 +145,30 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &eventType,
void *message, long *result)
{
Q_UNUSED(result);
if (eventType != "xcb_generic_event_t")
return false;

xcb_generic_event_t *event = reinterpret_cast<xcb_generic_event_t*>(message);
if ((event->response_type & ~0x80) != XCB_KEY_PRESS)
return false;

xcb_key_press_event_t *keyPressEvent = reinterpret_cast<xcb_key_press_event_t *>(event);

unsigned int keycode = keyPressEvent->detail;
unsigned int keystate = 0;
if(keyPressEvent->state & XCB_MOD_MASK_1)
keystate |= Mod1Mask;
if(keyPressEvent->state & XCB_MOD_MASK_CONTROL)
keystate |= ControlMask;
if(keyPressEvent->state & XCB_MOD_MASK_4)
keystate |= Mod4Mask;
if(keyPressEvent->state & XCB_MOD_MASK_SHIFT)
keystate |= ShiftMask;

activateShortcut(keycode,
// Mod1Mask == Alt, Mod4Mask == Meta
keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask));

xcb_key_press_event_t *kev = 0;
if (eventType == "xcb_generic_event_t") {
xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message);
if ((ev->response_type & 127) == XCB_KEY_PRESS)
kev = static_cast<xcb_key_press_event_t *>(message);
}

if (kev != 0) {
unsigned int keycode = kev->detail;
unsigned int keystate = 0;
if(kev->state & XCB_MOD_MASK_1)
keystate |= Mod1Mask;
if(kev->state & XCB_MOD_MASK_CONTROL)
keystate |= ControlMask;
if(kev->state & XCB_MOD_MASK_4)
keystate |= Mod4Mask;
if(kev->state & XCB_MOD_MASK_SHIFT)
keystate |= ShiftMask;

activateShortcut(keycode,
// Mod1Mask == Alt, Mod4Mask == Meta
keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask));
}
return false;
}

Expand Down

0 comments on commit 9a77d12

Please sign in to comment.