diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-30 02:30:47 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-30 02:30:47 +0200 |
commit | 5b819219889e78093e0dd32615adb6dcdc66cbcb (patch) | |
tree | 48dcc16ad34ab19a656ce862d8e4472e7ceb77e1 /qxt-mini/qxtglobalshortcut.cpp | |
parent | a4836eac5872d06d533e0130230c99148aeb4c7e (diff) |
fix linux hotkeys
Requested-by: @miniskipper and many others
Diffstat (limited to 'qxt-mini/qxtglobalshortcut.cpp')
-rw-r--r-- | qxt-mini/qxtglobalshortcut.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 298472b5..fc0984b6 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -61,13 +61,13 @@ void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() } QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate(QxtGlobalShortcutPrivate::tag) : - enabled(false), key(Qt::Key(0)), mods(Qt::NoModifier) + keystate(false), enabled(false), key(Qt::Key(0)), mods(Qt::NoModifier) { qDebug() << "qxt-mini: adding event filter"; } QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : - enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) + keystate(false), enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) { QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter(); } @@ -143,25 +143,49 @@ bool QxtGlobalShortcutPrivate::unsetShortcut() return res; } -void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) +void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods, bool is_down) { #ifndef Q_OS_MAC using IT = decltype(shortcuts.end()); const auto pair = qMakePair(nativeKey, nativeMods); IT it = shortcuts.find(pair); + bool once = false; + for (; it != shortcuts.end(); it++) { if (it.key() != pair) // DO NOT REMOVE break; + auto ptr = *it; + auto& priv = ptr->qxt_d(); + + if (priv.keystate == is_down) + { + continue; + } + + if (!once) + { + once = true; + qDebug() << "qxt-mini:" << (is_down ? "keydown" : "keyup") << priv.key << priv.mods; + } + + priv.keystate = is_down; + if (ptr->isEnabled()) - emit ptr->activated(); + emit ptr->activated(is_down); } #else QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); - if (shortcut && shortcut->isEnabled()) - emit shortcut->activated(); + + if (shortcut) + { + shortcut->qxt_d().keystate = false; + + if (shortcut->isEnabled()) + emit shortcut->activated(true); + } #endif } |