summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-30 20:48:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-30 20:48:09 +0200
commitc64c3c69dfed2d5d2af7b72b0489f52b28f854a8 (patch)
tree1c6995ca16437f7deaa1e4a6be88ea3f009ec328
parentf018bf4beeb15f346177dcee2b9e1a023627e7c4 (diff)
qxt-mini: fix numpad handling
-rw-r--r--qxt-mini/CMakeLists.txt1
-rw-r--r--qxt-mini/qxtglobal.h12
-rw-r--r--qxt-mini/qxtglobalshortcut_x11.cpp37
-rw-r--r--qxt-mini/x11-keymap.cpp46
-rw-r--r--qxt-mini/x11-keymap.hpp23
5 files changed, 78 insertions, 41 deletions
diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt
index 84e66732..b380e1b0 100644
--- a/qxt-mini/CMakeLists.txt
+++ b/qxt-mini/CMakeLists.txt
@@ -4,6 +4,7 @@ if(UNIX OR APPLE)
pkg_check_modules(xprotopkg REQUIRED xproto)
target_include_directories(opentrack-qxt-mini SYSTEM PRIVATE ${xprotopkg_INCLUDE_DIRS})
target_link_libraries(opentrack-qxt-mini X11)
+ add_definitions(-DQXT_BUILD)
else()
otr_prop(TARGET opentrack-qxt-mini LINK_FLAGS "-framework Carbon -framework CoreFoundation")
endif()
diff --git a/qxt-mini/qxtglobal.h b/qxt-mini/qxtglobal.h
index 6446b0ee..5ac72fb7 100644
--- a/qxt-mini/qxtglobal.h
+++ b/qxt-mini/qxtglobal.h
@@ -53,10 +53,18 @@
#ifdef BUILD_qxt_mini
# define QXT_BUILD
-# define BUILD_QXT_GUI
-# define BUILD_QXT
#endif
+#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
+# if defined(BUILD_QXT_GUI)
+# define QXT_EXPORT Q_DECL_EXPORT
+# else
+# define QXT_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define QXT_EXPORT
+#endif // BUILD_QXT_GUI
+
#ifdef QXT_BUILD
# if defined(BUILD_QXT_CORE)
# define QXT_CORE_EXPORT Q_DECL_EXPORT
diff --git a/qxt-mini/qxtglobalshortcut_x11.cpp b/qxt-mini/qxtglobalshortcut_x11.cpp
index b214a3a0..9106e25e 100644
--- a/qxt-mini/qxtglobalshortcut_x11.cpp
+++ b/qxt-mini/qxtglobalshortcut_x11.cpp
@@ -144,9 +144,7 @@ make_powerset(const t& arg, const xs&... args)
return ret;
}
-static auto evil_mods = make_powerset(LockMask, Mod3Mask, Mod5Mask);
-
-static Qt::KeyboardModifiers evil_qt_mods = Qt::KeypadModifier;
+static auto evil_mods = make_powerset(LockMask, Mod5Mask, Mod2Mask);
static inline quint32 filter_evil_mods(quint32 mods)
{
@@ -485,35 +483,36 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType,
if (keycode == 0)
return false;
- unsigned int keystate = 0;
- if(kev->state & XCB_MOD_MASK_1) // alt
- keystate |= Mod1Mask;
- if(kev->state & XCB_MOD_MASK_CONTROL) // ctrl
- keystate |= ControlMask;
- if(kev->state & XCB_MOD_MASK_4) // super aka win key
- keystate |= Mod4Mask;
- if(kev->state & XCB_MOD_MASK_SHIFT) //shift
- keystate |= ShiftMask;
- if(kev->state & XCB_MOD_MASK_2) // numlock
- keystate |= Mod2Mask;
+ quint32 keystate = xcb_mods_to_x11(kev->state);
keystate = filter_evil_mods(keystate);
QPair<KeySym, KeySym> sym_ = keycode_to_keysym(x11.display(), keycode, keystate, kev);
- KeySym sym = sym_.first;
+ KeySym sym = sym_.first, sym2 = sym_.second;
Qt::Key k; Qt::KeyboardModifiers mods;
- std::tie(k, mods) = x11_key_to_qt(x11.display(), sym, keystate);
- if (k != 0)
- activateShortcut(k, mods, !is_release);
+
+ {
+ std::tie(k, mods) = x11_key_to_qt(x11.display(), sym, keystate);
+
+ if (k != 0)
+ activateShortcut(k, mods, !is_release);
+ }
+
+ {
+ std::tie(k, mods) = x11_key_to_qt(x11.display(), sym2, keystate);
+
+ if (k != 0)
+ activateShortcut(k, mods, !is_release);
+ }
}
return false;
}
quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers)
{
- modifiers &= ~evil_qt_mods;
+ modifiers = x11_mods_to_qt(filter_evil_mods(qt_mods_to_x11(modifiers)));
return quint32(modifiers);
}
diff --git a/qxt-mini/x11-keymap.cpp b/qxt-mini/x11-keymap.cpp
index 16e55368..701c60bc 100644
--- a/qxt-mini/x11-keymap.cpp
+++ b/qxt-mini/x11-keymap.cpp
@@ -143,24 +143,25 @@ static tt numpad_keymap[] = {
{ Qt::Key_7, XK_KP_7 },
{ Qt::Key_8, XK_KP_8 },
{ Qt::Key_9, XK_KP_9 },
- { Qt::Key_5, XK_KP_Begin },
+
{ Qt::Key_Space, XK_KP_Space },
{ Qt::Key_Tab, XK_KP_Tab },
{ Qt::Key_F1, XK_KP_F1 },
{ Qt::Key_F2, XK_KP_F2 },
{ Qt::Key_F3, XK_KP_F3 },
{ Qt::Key_F4, XK_KP_F4 },
- { Qt::Key_Home, XK_KP_Home },
- { Qt::Key_End, XK_KP_End },
- { Qt::Key_Left, XK_KP_Left },
- { Qt::Key_Right, XK_KP_Right },
- { Qt::Key_Up, XK_KP_Up },
- { Qt::Key_Down, XK_KP_Down },
- { Qt::Key_PageUp, XK_KP_Page_Up },
- { Qt::Key_PageUp, XK_KP_Prior },
- { Qt::Key_PageDown, XK_KP_Page_Down },
- { Qt::Key_PageDown, XK_KP_Next },
- { Qt::Key_Insert, XK_KP_Insert },
+
+ { Qt::Key_1, XK_KP_End },
+ { Qt::Key_2, XK_KP_Down },
+ { Qt::Key_3, XK_KP_Page_Down },
+ { Qt::Key_4, XK_KP_Left },
+ { Qt::Key_5, XK_KP_Begin },
+ { Qt::Key_6, XK_KP_Right },
+ { Qt::Key_7, XK_KP_Home },
+ { Qt::Key_8, XK_KP_Up },
+ { Qt::Key_9, XK_KP_Page_Up },
+ { Qt::Key_0, XK_KP_Insert },
+
{ Qt::Key_Delete, XK_KP_Delete },
{ Qt::Key_Equal, XK_KP_Equal },
{ Qt::Key_Asterisk, XK_KP_Multiply },
@@ -210,7 +211,7 @@ std::vector<quint32> qt_key_to_x11(Display*, Qt::Key k, Qt::KeyboardModifiers)
return ret;
}
QXT_GUI_EXPORT
-static Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods)
+Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods)
{
Qt::KeyboardModifiers ret(0);
@@ -294,4 +295,23 @@ QPair<KeySym, KeySym> keycode_to_keysym(Display* disp,
return ret;
}
+
+QXT_GUI_EXPORT
+quint32 xcb_mods_to_x11(quint32 mods)
+{
+ unsigned int keystate = 0;
+
+ if(mods & XCB_MOD_MASK_1) // alt
+ keystate |= Mod1Mask;
+ if(mods & XCB_MOD_MASK_CONTROL) // ctrl
+ keystate |= ControlMask;
+ if(mods & XCB_MOD_MASK_4) // super aka win key
+ keystate |= Mod4Mask;
+ if(mods & XCB_MOD_MASK_SHIFT) //shift
+ keystate |= ShiftMask;
+ if(mods & XCB_MOD_MASK_2) // numlock
+ keystate |= Mod2Mask;
+
+ return keystate;
+}
#endif
diff --git a/qxt-mini/x11-keymap.hpp b/qxt-mini/x11-keymap.hpp
index 2c737c77..52e2ebea 100644
--- a/qxt-mini/x11-keymap.hpp
+++ b/qxt-mini/x11-keymap.hpp
@@ -10,6 +10,8 @@
#include <QHash>
#include <QPair>
+#include "qxtglobal.h"
+
#include <vector>
#include <tuple>
@@ -17,17 +19,24 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-QXT_GUI_EXPORT
-std::vector<quint32> qt_key_to_x11(Display* disp, Qt::Key k, Qt::KeyboardModifiers m);
+QXT_EXPORT
+std::vector<quint32> qt_key_to_x11(Display* disp,
+ Qt::Key k, Qt::KeyboardModifiers m);
-QXT_GUI_EXPORT
-std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp, quint32 keycode, quint32 mods);
+QXT_EXPORT
+std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp,
+ quint32 keycode, quint32 mods);
+
+QXT_EXPORT QPair<KeySym, KeySym> keycode_to_keysym(Display* disp,
+ quint32 keycode, quint32 keystate,
+ xcb_key_press_event_t const* kev);
+
+QXT_EXPORT quint32 qt_mods_to_x11(Qt::KeyboardModifiers modifiers);
QXT_GUI_EXPORT
-QPair<KeySym, KeySym> keycode_to_keysym(Display* disp, quint32 keycode, quint32 keystate,
- xcb_key_press_event_t const* kev);
+Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods);
QXT_GUI_EXPORT
-quint32 qt_mods_to_x11(Qt::KeyboardModifiers modifiers);
+quint32 xcb_mods_to_x11(quint32 mods);
#endif