no logging, qhash using uint64

This commit is contained in:
mrbesen 2021-12-15 01:11:24 +01:00
parent 336b6f5780
commit 66d741954d
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
3 changed files with 6 additions and 10 deletions

View File

@ -39,7 +39,7 @@ int QxtGlobalShortcutPrivate::ref = 0;
QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0;
# endif
#endif // Q_OS_MAC
QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts;
QHash<quint64, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts;
QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier)
{
@ -81,7 +81,7 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
nativeMods = nativeModifiers(mods);
const bool res = registerShortcut(nativeKey, nativeMods);
if (res)
shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p());
shortcuts.insert(((quint64) nativeKey << 32) | nativeMods, &qxt_p());
else
qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString();
return res;
@ -90,10 +90,10 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
bool QxtGlobalShortcutPrivate::unsetShortcut()
{
bool res = false;
if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p())
if (shortcuts.value(((quint64) nativeKey << 32) | nativeMods) == &qxt_p())
res = unregisterShortcut(nativeKey, nativeMods);
if (res)
shortcuts.remove(qMakePair(nativeKey, nativeMods));
shortcuts.remove(((quint64) nativeKey << 32) | nativeMods);
else
qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString();
key = Qt::Key(0);
@ -105,7 +105,7 @@ bool QxtGlobalShortcutPrivate::unsetShortcut()
void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods)
{
QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods));
QxtGlobalShortcut* shortcut = shortcuts.value(((quint64) nativeKey << 32) | nativeMods);
if (shortcut && shortcut->isEnabled())
emit shortcut->activated();
}

View File

@ -81,7 +81,7 @@ private:
static bool registerShortcut(quint32 nativeKey, quint32 nativeMods);
static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods);
static QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> shortcuts;
static QHash<quint64, QxtGlobalShortcut*> shortcuts;
};
#endif // QXTGLOBALSHORTCUT_P_H

View File

@ -36,8 +36,6 @@
#include <xcb/xcb.h>
#include <X11/Xutil.h>
#include <Log.h>
namespace {
const QVector<quint32> maskModifiers = QVector<quint32>()
@ -249,10 +247,8 @@ quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key, Qt::KeyboardModifie
return 0;
if(modifiers & Qt::KeypadModifier) {
Log::info << "resolveing keypad code: " << QKeySequence(key).toString().toStdString();
quint32 code = getNumpadKeyCode(x11.display(), key);
if(code != 0) {
Log::info << "resolved keypad code: " << code;
return code;
}
}