diff options
Diffstat (limited to 'qxt-mini')
-rw-r--r-- | qxt-mini/CMakeLists.txt | 16 | ||||
-rw-r--r-- | qxt-mini/lang/de_DE.ts | 4 | ||||
-rw-r--r-- | qxt-mini/lang/zh_CN.ts | 4 | ||||
-rw-r--r-- | qxt-mini/powerset.hpp | 5 | ||||
-rw-r--r-- | qxt-mini/qplatformnativeinterface.h | 99 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut.cpp | 38 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut.h | 8 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut_mac.cpp | 17 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut_p.h | 5 | ||||
-rw-r--r-- | qxt-mini/qxtglobalshortcut_x11.cpp | 67 | ||||
-rw-r--r-- | qxt-mini/x11-keymap.cpp | 17 | ||||
-rw-r--r-- | qxt-mini/x11-keymap.hpp | 22 |
12 files changed, 102 insertions, 200 deletions
diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt index 39f3525c..1b2496f6 100644 --- a/qxt-mini/CMakeLists.txt +++ b/qxt-mini/CMakeLists.txt @@ -1,13 +1,13 @@ if(UNIX OR APPLE) + set(self opentrack-qxt-mini) + include_directories(SYSTEM ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) otr_module(qxt-mini NO-COMPAT BIN) - if(NOT 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) + if(APPLE) + find_library(CoreFoundation CoreFoundation) + find_library(Carbon Carbon) + target_link_options(${self} PUBLIC -framework Carbon -I ${CoreFoundation}) else() - set_property(TARGET opentrack-qxt-mini - APPEND_STRING PROPERTY - LINK_FLAGS "-framework Carbon -framework CoreFoundation ") + otr_pkgconfig(${self} x11 xcb xproto) endif() + target_compile_definitions(${self} PRIVATE -DQXT_BUILD) endif() diff --git a/qxt-mini/lang/de_DE.ts b/qxt-mini/lang/de_DE.ts new file mode 100644 index 00000000..1552582e --- /dev/null +++ b/qxt-mini/lang/de_DE.ts @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +</TS> diff --git a/qxt-mini/lang/zh_CN.ts b/qxt-mini/lang/zh_CN.ts new file mode 100644 index 00000000..e5ca8aa9 --- /dev/null +++ b/qxt-mini/lang/zh_CN.ts @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="zh_CN"> +</TS> diff --git a/qxt-mini/powerset.hpp b/qxt-mini/powerset.hpp index ebb02ba8..901ff0c7 100644 --- a/qxt-mini/powerset.hpp +++ b/qxt-mini/powerset.hpp @@ -1,7 +1,5 @@ #pragma once -#include "compat/macros.hpp" - #include <type_traits> #include <cinttypes> #include <vector> @@ -66,8 +64,7 @@ private: }; template<typename t, typename... xs> -auto force_inline -make_powerset(const t& arg, const xs&... args) +inline auto make_powerset(const t& arg, const xs&... args) { using cnt = std::integral_constant<std::uintptr_t, sizeof...(xs)+1>; using p = powerset<t, cnt::value>; diff --git a/qxt-mini/qplatformnativeinterface.h b/qxt-mini/qplatformnativeinterface.h deleted file mode 100644 index eaa24a9e..00000000 --- a/qxt-mini/qplatformnativeinterface.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLATFORMNATIVEINTERFACE_H -#define QPLATFORMNATIVEINTERFACE_H - -// -// W A R N I N G -// ------------- -// -// This file is part of the QPA API and is not meant to be used -// in applications. Usage of this API may make your code -// source and binary incompatible with future versions of Qt. -// - -#include <QtGui/qwindowdefs.h> -#include <QtCore/QObject> -#include <QtCore/QVariant> - -QT_BEGIN_NAMESPACE - - -class QOpenGLContext; -class QScreen; -class QWindow; -class QPlatformWindow; -class QBackingStore; - -class Q_GUI_EXPORT QPlatformNativeInterface : public QObject -{ - Q_OBJECT -public: - virtual void *nativeResourceForIntegration(const QByteArray &resource); - virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); - virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen); - virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); - virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore); - - typedef void * (*NativeResourceForIntegrationFunction)(); - typedef void * (*NativeResourceForContextFunction)(QOpenGLContext *context); - typedef void * (*NativeResourceForScreenFunction)(QScreen *screen); - typedef void * (*NativeResourceForWindowFunction)(QWindow *window); - typedef void * (*NativeResourceForBackingStoreFunction)(QBackingStore *backingStore); - virtual NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource); - virtual NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource); - virtual NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource); - virtual NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource); - virtual NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource); - - virtual QVariantMap windowProperties(QPlatformWindow *window) const; - virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const; - virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; - virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); - -Q_SIGNALS: - void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName); -}; - -QT_END_NAMESPACE - -#endif // QPLATFORMNATIVEINTERFACE_H diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index b680c5f7..dec11dc4 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -36,12 +36,11 @@ #include <QtDebug> #include <QtGlobal> -QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; +#ifdef __GNUG__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif -struct QxtGlobalShortcutPrivate::event_filter_installer -{ - static void ensure_event_filter(); -}; +QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() { @@ -51,9 +50,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 } @@ -61,7 +59,7 @@ void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate(QxtGlobalShortcutPrivate::tag) : keystate(false), enabled(false), key(Qt::Key(0)), mods(Qt::NoModifier) { - qDebug() << "qxt-mini: adding event filter"; + //qDebug() << "qxt-mini: adding event filter"; } QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : @@ -81,8 +79,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 +94,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 +103,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 +132,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; } @@ -182,7 +180,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ shortcut->qxt_d().keystate = false; if (shortcut->isEnabled()) - emit shortcut->activated(true); + emit shortcut->activated(is_down); } #endif } @@ -221,7 +219,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) : QObject(parent) { - QXT_INIT_PRIVATE(QxtGlobalShortcut); + QXT_INIT_PRIVATE(QxtGlobalShortcut) } /*! @@ -230,7 +228,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 +245,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 +257,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.h b/qxt-mini/qxtglobalshortcut.h index be62a984..9f8dcf9e 100644 --- a/qxt-mini/qxtglobalshortcut.h +++ b/qxt-mini/qxtglobalshortcut.h @@ -1,4 +1,4 @@ -#ifndef QXTGLOBALSHORTCUT_H +#pragma once /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. @@ -46,8 +46,8 @@ class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject bool keystate; public: - explicit QxtGlobalShortcut(QObject* parent = 0); - explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + explicit QxtGlobalShortcut(QObject* parent = nullptr); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = nullptr); ~QxtGlobalShortcut() override; QKeySequence shortcut() const; @@ -62,5 +62,3 @@ public Q_SLOTS: Q_SIGNALS: void activated(bool keydown = true); }; - -#endif // QXTGLOBALSHORTCUT_H diff --git a/qxt-mini/qxtglobalshortcut_mac.cpp b/qxt-mini/qxtglobalshortcut_mac.cpp index d7cd7f84..c91d763d 100644 --- a/qxt-mini/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/qxtglobalshortcut_mac.cpp @@ -49,13 +49,14 @@ OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, { Q_UNUSED(nextHandler); Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + if (GetEventClass(event) == kEventClassKeyboard && (GetEventKind(event) == kEventHotKeyPressed || GetEventKind(event) == kEventHotKeyReleased)) { EventHotKeyID keyID; GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); Identifier id = keyIDs.key(keyID.id); - if(id != Identifier()) - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, true); + if(id != Identifier()) { + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first, GetEventKind(event) == kEventHotKeyPressed); + } } return noErr; } @@ -233,10 +234,12 @@ bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativ if (!qxt_mac_handler_installed) { qxt_mac_handler_installed = true; - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + EventTypeSpec t[2]; + t[0].eventClass = kEventClassKeyboard; + t[0].eventKind = kEventHotKeyPressed; + t[1].eventClass = kEventClassKeyboard; + t[1].eventKind = kEventHotKeyReleased; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 2, t, NULL, NULL); } EventHotKeyID keyID; 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 2609aa7c..01894cfc 100644 --- a/qxt-mini/qxtglobalshortcut_x11.cpp +++ b/qxt-mini/qxtglobalshortcut_x11.cpp @@ -37,7 +37,7 @@ #include <QPair> #include <QKeyEvent> #include <QApplication> -#include "qplatformnativeinterface.h" +#include <qpa/qplatformnativeinterface.h> #include "x11-keymap.hpp" @@ -69,6 +69,9 @@ using pair = QPair<quint32, quint32>; struct keybinding final { + keybinding(const keybinding&) = default; + keybinding& operator=(const keybinding&) = default; + quint32 code, mods; int refcnt; @@ -93,7 +96,7 @@ public: static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) { - Q_UNUSED(display); + Q_UNUSED(display) switch (event->error_code) { case BadAccess: @@ -135,7 +138,7 @@ public: bool isValid() { - return m_display != 0; + return m_display; } Display *display() @@ -154,13 +157,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); + auto [ native_sym, native_mods ] = x; + int native_code = XKeysymToKeycode(display(), native_sym); - if (keybinding::incf(native_code, native_mods)) + if (keybinding::incf((unsigned)native_code, native_mods)) { QxtX11ErrorHandler errorHandler; @@ -170,8 +172,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); } @@ -179,7 +181,15 @@ public: if (errorHandler.error) { qDebug() << "qxt-mini: error while binding to" << code << mods; - ungrabKey(code, mods); + for (const auto& set : evil_mods.sets()) + { + quint32 m = mods; + + for (int value : set) + m |= (unsigned)value; + + XUngrabKey(display(), native_code, m, rootWindow()); + } ret = false; } } @@ -193,12 +203,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); + auto [ native_sym, native_mods ] = x; + int native_code = XKeysymToKeycode(display(), native_sym); - 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,10 +217,10 @@ public: { quint32 m = mods; - for (auto value : set) - m |= value; + for (int value : set) + m |= (unsigned)value; - XUngrabKey(display(), code, m, rootWindow()); + XUngrabKey(display(), native_code, m, rootWindow()); } if (errorHandler.error) @@ -345,26 +355,27 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, (void) XkbSetDetectableAutoRepeat(x11.display(), True, &val); - if (val) - qDebug() << "qxt-mini: fixed x11 autorepeat"; - else + if (!val) qDebug() << "qxt-mini: can't fix x11 autorepeat"; } } bool is_release = false; - xcb_key_press_event_t *kev = 0; + static_assert(std::is_same_v<xcb_key_press_event_t, xcb_key_release_event_t>); + + 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) { case XCB_KEY_RELEASE: is_release = true; - /*FALLTHROUGH*/ + [[fallthrough]]; case XCB_KEY_PRESS: kev = static_cast<xcb_key_press_event_t *>(message); - /*FALLTHROUGH*/ + break; + default: break; } @@ -400,21 +411,19 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, keystate = filter_evil_mods(keystate); - QPair<KeySym, KeySym> sym_ = keycode_to_keysym(x11.display(), keycode, keystate, kev); - KeySym sym = sym_.first, sym2 = sym_.second; + auto [ sym, sym2 ] = keycode_to_keysym(x11.display(), keycode, keystate, kev); 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 a42752b3..fed01cc2 100644 --- a/qxt-mini/x11-keymap.cpp +++ b/qxt-mini/x11-keymap.cpp @@ -174,7 +174,6 @@ static tt numpad_keymap[] = { { Qt::Key_ScrollLock, XK_Scroll_Lock }, }; -QXT_GUI_EXPORT quint32 qt_mods_to_x11(Qt::KeyboardModifiers modifiers) { quint32 mods = 0; @@ -193,7 +192,6 @@ quint32 qt_mods_to_x11(Qt::KeyboardModifiers modifiers) return mods; } -QXT_GUI_EXPORT std::vector<quint32> qt_key_to_x11(Display*, Qt::Key k, Qt::KeyboardModifiers) { std::vector<quint32> ret; @@ -212,10 +210,10 @@ std::vector<quint32> qt_key_to_x11(Display*, Qt::Key k, Qt::KeyboardModifiers) return ret; } -QXT_GUI_EXPORT + Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods) { - Qt::KeyboardModifiers ret(0); + int ret{0}; if (mods & Mod1Mask) ret |= Qt::AltModifier; @@ -226,10 +224,9 @@ Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods) if (mods & ShiftMask) ret |= Qt::ShiftModifier; - return ret; + return {ret}; } -QXT_GUI_EXPORT std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp, quint32 keycode, quint32 mods) { (void)disp; @@ -243,11 +240,10 @@ 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)); } -QXT_GUI_EXPORT QPair<KeySym, KeySym> keycode_to_keysym(Display* disp, quint32 keycode, quint32 keystate, xcb_key_press_event_t const* kev) @@ -282,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; @@ -298,10 +294,9 @@ QPair<KeySym, KeySym> keycode_to_keysym(Display* disp, return ret; } -QXT_GUI_EXPORT quint32 xcb_mods_to_x11(quint32 mods) { - unsigned int keystate = 0; + unsigned keystate = 0; if(mods & XCB_MOD_MASK_1) // alt keystate |= Mod1Mask; diff --git a/qxt-mini/x11-keymap.hpp b/qxt-mini/x11-keymap.hpp index 52e2ebea..a6f2a061 100644 --- a/qxt-mini/x11-keymap.hpp +++ b/qxt-mini/x11-keymap.hpp @@ -19,24 +19,20 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> -QXT_EXPORT -std::vector<quint32> qt_key_to_x11(Display* disp, - Qt::Key k, Qt::KeyboardModifiers m); +std::vector<quint32> +qt_key_to_x11(Display* disp, Qt::Key k, Qt::KeyboardModifiers m); -QXT_EXPORT -std::tuple<Qt::Key, Qt::KeyboardModifiers> x11_key_to_qt(Display* disp, - quint32 keycode, quint32 mods); +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); +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); +quint32 qt_mods_to_x11(Qt::KeyboardModifiers modifiers); -QXT_GUI_EXPORT Qt::KeyboardModifiers x11_mods_to_qt(quint32 mods); - -QXT_GUI_EXPORT quint32 xcb_mods_to_x11(quint32 mods); #endif |