diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-06-26 15:38:32 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-06-26 15:38:32 +0200 |
commit | 7ee91f240cf51b94fdeed332a69da99c59ecd215 (patch) | |
tree | d9fdebd6e8d08125dccc80ddfbde123e2746dff9 /qxt-mini | |
parent | 507557cefbbee87a700de89aa515273d8f1820c7 (diff) |
qxt-mini: appease clang
Diffstat (limited to 'qxt-mini')
-rw-r--r-- | qxt-mini/qxtglobalshortcut.cpp | 30 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut_p.h | 5 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut_x11.cpp | 27 | ||||
-rw-r--r-- | qxt-mini/x11-keymap.cpp | 8 |
4 files changed, 30 insertions, 40 deletions
diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index b680c5f7..69514f88 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -38,11 +38,6 @@ QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; -struct QxtGlobalShortcutPrivate::event_filter_installer -{ - static void ensure_event_filter(); -}; - void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() { #ifndef Q_OS_MAC @@ -51,9 +46,8 @@ void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() { static QxtGlobalShortcutPrivate filter(QxtGlobalShortcutPrivate::tag {}); static bool installed = - (instance->installNativeEventFilter(&filter), - true); - Q_UNUSED(installed); + ((void)instance->installNativeEventFilter(&filter), true); + Q_UNUSED(installed) } #endif } @@ -81,8 +75,8 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) if (shortcut.toString() == "") return false; Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier; - key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key(shortcut[0] & ~allMods); - mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); + key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((unsigned)shortcut[0] & ~allMods); + mods = shortcut.isEmpty() ? Qt::KeyboardModifier(0) : Qt::KeyboardModifiers((unsigned)shortcut[0] & allMods); const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); @@ -96,7 +90,7 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) #endif } else - qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); + qWarning() << "QxtGlobalShortcut failed to register:" << shortcut; return res; } @@ -105,10 +99,10 @@ bool QxtGlobalShortcutPrivate::unsetShortcut() if (key == Qt::Key(0)) return true; - bool res = false; const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); #ifdef Q_OS_MAC + bool res = false; if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) res = unregisterShortcut(nativeKey, nativeMods); if (res) @@ -134,10 +128,10 @@ bool QxtGlobalShortcutPrivate::unsetShortcut() } if (!found) qDebug() << "qxt-mini: can't find shortcut for" << key << mods; - res = unregisterShortcut(nativeKey, nativeMods); + bool res = unregisterShortcut(nativeKey, nativeMods); #endif key = Qt::Key(0); - mods = Qt::KeyboardModifiers(0); + mods = Qt::KeyboardModifier(0); return res; } @@ -221,7 +215,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) : QObject(parent) { - QXT_INIT_PRIVATE(QxtGlobalShortcut); + QXT_INIT_PRIVATE(QxtGlobalShortcut) } /*! @@ -230,7 +224,7 @@ QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) : QObject(parent) { - QXT_INIT_PRIVATE(QxtGlobalShortcut); + QXT_INIT_PRIVATE(QxtGlobalShortcut) setShortcut(shortcut); } @@ -247,7 +241,7 @@ QxtGlobalShortcut::~QxtGlobalShortcut() \property QxtGlobalShortcut::shortcut \brief the shortcut key sequence - \bold {Note:} Notice that corresponding key press and release events are not + \note Notice that corresponding key press and release events are not delivered for registered global shortcuts even if they are disabled. Also, comma separated key sequences are not supported. Only the first part is used: @@ -259,7 +253,7 @@ QxtGlobalShortcut::~QxtGlobalShortcut() */ QKeySequence QxtGlobalShortcut::shortcut() const { - return QKeySequence(qxt_d().key | qxt_d().mods); + return QKeySequence((int)(qxt_d().key | qxt_d().mods)); } bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h index 7864a7d8..be708ba6 100644 --- a/qxt-mini/qxtglobalshortcut_p.h +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -54,13 +54,12 @@ public: bool unsetShortcut(); static bool error; - static bool eventFilter(void* message); bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) override; static void activateShortcut(quint32 nativeKey, quint32 nativeMods, bool is_down); private: - struct event_filter_installer; + struct event_filter_installer { static void ensure_event_filter(); }; friend struct event_filter_installer; struct tag {}; explicit QxtGlobalShortcutPrivate(tag); @@ -72,8 +71,6 @@ private: static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); static QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> shortcuts; - - static void ensure_event_filter(); }; #endif // QXTGLOBALSHORTCUT_P_H diff --git a/qxt-mini/qxtglobalshortcut_x11.cpp b/qxt-mini/qxtglobalshortcut_x11.cpp index adf25b6b..a37b1b0b 100644 --- a/qxt-mini/qxtglobalshortcut_x11.cpp +++ b/qxt-mini/qxtglobalshortcut_x11.cpp @@ -93,7 +93,7 @@ public: static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) { - Q_UNUSED(display); + Q_UNUSED(display) switch (event->error_code) { case BadAccess: @@ -135,7 +135,7 @@ public: bool isValid() { - return m_display != 0; + return m_display; } Display *display() @@ -154,13 +154,13 @@ public: const std::vector<pair> keycodes = native_key(Qt::Key(code), Qt::KeyboardModifiers(mods)); bool ret = true; - for (pair x : keycodes) + for (const pair& x : keycodes) { int native_code = x.first, native_mods = x.second; native_code = XKeysymToKeycode(display(), native_code); - if (keybinding::incf(native_code, native_mods)) + if (keybinding::incf((unsigned)native_code, native_mods)) { QxtX11ErrorHandler errorHandler; @@ -170,8 +170,8 @@ public: { quint32 m = native_mods; - for (auto value : set) - m |= value; + for (int value : set) + m |= (unsigned)value; XGrabKey(display(), native_code, m, rootWindow(), True, GrabModeAsync, GrabModeAsync); } @@ -193,12 +193,12 @@ public: const std::vector<pair> keycodes = native_key(Qt::Key(code), Qt::KeyboardModifiers(mods)); bool ret = true; - for (pair x : keycodes) + for (const pair& x : keycodes) { int native_code = x.first, native_mods = x.second; native_code = XKeysymToKeycode(display(), native_code); - if (keybinding::decf(native_code, native_mods)) + if (keybinding::decf((unsigned)native_code, native_mods)) { QxtX11ErrorHandler errorHandler; XUngrabKey(display(), native_code, native_mods, rootWindow()); @@ -207,8 +207,8 @@ public: { quint32 m = mods; - for (auto value : set) - m |= value; + for (int value : set) + m |= (unsigned)value; XUngrabKey(display(), code, m, rootWindow()); } @@ -354,7 +354,7 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, bool is_release = false; - xcb_key_press_event_t *kev = 0; + xcb_key_press_event_t *kev = nullptr; if (eventType == "xcb_generic_event_t") { xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); switch (ev->response_type & 127) @@ -405,16 +405,15 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, Qt::Key k; Qt::KeyboardModifiers mods; - { - std::tie(k, mods) = x11_key_to_qt(x11.display(), sym, keystate); + std::tie(k, mods) = x11_key_to_qt(x11.display(), (quint32)sym, keystate); if (k != 0) activateShortcut(k, mods, !is_release); } { - std::tie(k, mods) = x11_key_to_qt(x11.display(), sym2, keystate); + std::tie(k, mods) = x11_key_to_qt(x11.display(), (quint32)sym2, keystate); if (k != 0) activateShortcut(k, mods, !is_release); diff --git a/qxt-mini/x11-keymap.cpp b/qxt-mini/x11-keymap.cpp index 4b7f56f5..fed01cc2 100644 --- a/qxt-mini/x11-keymap.cpp +++ b/qxt-mini/x11-keymap.cpp @@ -213,7 +213,7 @@ std::vector<quint32> qt_key_to_x11(Display*, Qt::Key k, Qt::KeyboardModifiers) Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods) { - Qt::KeyboardModifiers ret{0}; + int ret{0}; if (mods & Mod1Mask) ret |= Qt::AltModifier; @@ -224,7 +224,7 @@ Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods) if (mods & ShiftMask) ret |= Qt::ShiftModifier; - return ret; + return {ret}; } std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp, quint32 keycode, quint32 mods) @@ -240,7 +240,7 @@ std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp, quint32 return t(k, x11_mods_to_qt(mods)); } - return t(Qt::Key(0), Qt::KeyboardModifiers(0)); + return t(Qt::Key(0), Qt::KeyboardModifier(0)); } @@ -278,7 +278,7 @@ QPair<KeySym, KeySym> keycode_to_keysym(Display* disp, static char bytes[255+1]; KeySym sym = 0; - int len = XLookupString(&ev, bytes, 255, &sym, NULL); + int len = XLookupString(&ev, bytes, 255, &sym, nullptr); if (len <= 0 || len > 255) { len = 0; |