diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-17 23:31:41 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-20 17:47:42 +0200 |
commit | 5b1befa31a9851397d56363f058568094d11f5f3 (patch) | |
tree | f1be4f68da64a59d6502e9e45488436417c68e5d /src/plugins/platforms | |
parent | 9166abcd997f57625c17db8e8734988ff303217e (diff) |
Add QEvdevKeyMapper platform interface
Task-number: QTBUG-84220
Change-Id: I4f3a54415c5509b4bde486b54c56b0e05976bac6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms')
4 files changed, 35 insertions, 50 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index 3ce78623fa..befab97baa 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -432,39 +432,26 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::na QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const { -#if QT_CONFIG(evdev) - if (function == QEglFSFunctions::loadKeymapTypeIdentifier()) - return QFunctionPointer(loadKeymapStatic); - else if (function == QEglFSFunctions::switchLangTypeIdentifier()) - return QFunctionPointer(switchLangStatic); -#endif - return qt_egl_device_integration()->platformFunction(function); } -void QEglFSIntegration::loadKeymapStatic(const QString &filename) -{ #if QT_CONFIG(evdev) - QEglFSIntegration *self = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); - if (self->m_kbdMgr) - self->m_kbdMgr->loadKeymap(filename); +void QEglFSIntegration::loadKeymap(const QString &filename) +{ + if (m_kbdMgr) + m_kbdMgr->loadKeymap(filename); else qWarning("QEglFSIntegration: Cannot load keymap, no keyboard handler found"); -#else - Q_UNUSED(filename); -#endif } -void QEglFSIntegration::switchLangStatic() +void QEglFSIntegration::switchLang() { -#if QT_CONFIG(evdev) - QEglFSIntegration *self = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); - if (self->m_kbdMgr) - self->m_kbdMgr->switchLang(); + if (m_kbdMgr) + m_kbdMgr->switchLang(); else qWarning("QEglFSIntegration: Cannot switch language, no keyboard handler found"); -#endif } +#endif void QEglFSIntegration::createInputHandlers() { diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h index babcbfaaa4..9bc24f36f9 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h @@ -59,6 +59,7 @@ #include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformopenglcontext.h> #include <qpa/qplatformscreen.h> +#include <QtGui/private/qkeymapper_p.h> QT_BEGIN_NAMESPACE @@ -68,8 +69,11 @@ class QFbVtHandler; class QEvdevKeyboardManager; class Q_EGLFS_EXPORT QEglFSIntegration : public QPlatformIntegration, public QPlatformNativeInterface +#if QT_CONFIG(evdev) + , public QPlatformInterface::Private::QEvdevKeyMapper +#endif #ifndef QT_NO_OPENGL - , public QPlatformInterface::Private::QEGLIntegration + , public QPlatformInterface::Private::QEGLIntegration #endif { public: @@ -116,11 +120,14 @@ public: QPointer<QWindow> pointerWindow() { return m_pointerWindow; } void setPointerWindow(QWindow *pointerWindow) { m_pointerWindow = pointerWindow; } +#if QT_CONFIG(evdev) + void loadKeymap(const QString &filename) override; + void switchLang() override; +#endif + private: EGLNativeDisplayType nativeDisplay() const; void createInputHandlers(); - static void loadKeymapStatic(const QString &filename); - static void switchLangStatic(); EGLDisplay m_display; QPlatformInputContext *m_inputContext; diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index cea486db21..61c4fdf768 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -70,8 +70,6 @@ #include <QtInputSupport/private/qtslib_p.h> #endif -#include <QtPlatformHeaders/private/qlinuxfbfunctions_p.h> - QT_BEGIN_NAMESPACE QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList) @@ -181,40 +179,26 @@ QPlatformNativeInterface *QLinuxFbIntegration::nativeInterface() const QFunctionPointer QLinuxFbIntegration::platformFunction(const QByteArray &function) const { -#if QT_CONFIG(evdev) - if (function == QLinuxFbFunctions::loadKeymapTypeIdentifier()) - return QFunctionPointer(loadKeymapStatic); - else if (function == QLinuxFbFunctions::switchLangTypeIdentifier()) - return QFunctionPointer(switchLangStatic); -#else Q_UNUSED(function); -#endif - return 0; } -void QLinuxFbIntegration::loadKeymapStatic(const QString &filename) -{ #if QT_CONFIG(evdev) - QLinuxFbIntegration *self = static_cast<QLinuxFbIntegration *>(QGuiApplicationPrivate::platformIntegration()); - if (self->m_kbdMgr) - self->m_kbdMgr->loadKeymap(filename); +void QLinuxFbIntegration::loadKeymap(const QString &filename) +{ + if (m_kbdMgr) + m_kbdMgr->loadKeymap(filename); else qWarning("QLinuxFbIntegration: Cannot load keymap, no keyboard handler found"); -#else - Q_UNUSED(filename); -#endif } -void QLinuxFbIntegration::switchLangStatic() +void QLinuxFbIntegration::switchLang() { -#if QT_CONFIG(evdev) - QLinuxFbIntegration *self = static_cast<QLinuxFbIntegration *>(QGuiApplicationPrivate::platformIntegration()); - if (self->m_kbdMgr) - self->m_kbdMgr->switchLang(); + if (m_kbdMgr) + m_kbdMgr->switchLang(); else qWarning("QLinuxFbIntegration: Cannot switch language, no keyboard handler found"); -#endif } +#endif QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index af6bd1d630..1e671ee7fc 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -42,6 +42,7 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformnativeinterface.h> +#include <QtGui/private/qkeymapper_p.h> QT_BEGIN_NAMESPACE @@ -51,6 +52,9 @@ class QFbVtHandler; class QEvdevKeyboardManager; class QLinuxFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface +#if QT_CONFIG(evdev) + , public QPlatformInterface::Private::QEvdevKeyMapper +#endif { public: QLinuxFbIntegration(const QStringList ¶mList); @@ -74,10 +78,13 @@ public: QFunctionPointer platformFunction(const QByteArray &function) const override; +#if QT_CONFIG(evdev) + void loadKeymap(const QString &filename) override; + void switchLang() override; +#endif + private: void createInputHandlers(); - static void loadKeymapStatic(const QString &filename); - static void switchLangStatic(); QFbScreen *m_primaryScreen; QPlatformInputContext *m_inputContext; |