diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index 7f6c48fb047..ad76bb095a0 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -1245,7 +1245,7 @@ qt_feature("system-xcb-xinput" PRIVATE SYSTEM_LIBRARY DISABLE INPUT_bundled_xcb_xinput STREQUAL 'yes' EMIT_IF QT_FEATURE_xcb ) -qt_feature("xkbcommon" PRIVATE +qt_feature("xkbcommon" PUBLIC LABEL "xkbcommon" CONDITION XKB_FOUND ) diff --git a/src/gui/kernel/qguiapplication_platform.h b/src/gui/kernel/qguiapplication_platform.h index 98e19427ae7..b3e753a9f49 100644 --- a/src/gui/kernel/qguiapplication_platform.h +++ b/src/gui/kernel/qguiapplication_platform.h @@ -30,6 +30,11 @@ struct wl_seat; struct wl_keyboard; struct wl_pointer; struct wl_touch; + +#if QT_CONFIG(xkbcommon) +struct xkb_context; +#endif + #endif #if defined(Q_OS_VISIONOS) || defined(Q_QDOC) @@ -74,6 +79,9 @@ struct Q_GUI_EXPORT QWaylandApplication virtual wl_touch *touch() const = 0; virtual uint lastInputSerial() const = 0; virtual wl_seat *lastInputSeat() const = 0; +#if QT_CONFIG(xkbcommon) + virtual xkb_context *xkbContext() const = 0; +#endif }; #endif diff --git a/src/gui/platform/unix/qunixnativeinterface.cpp b/src/gui/platform/unix/qunixnativeinterface.cpp index 2291467740d..cfdeff40aa5 100644 --- a/src/gui/platform/unix/qunixnativeinterface.cpp +++ b/src/gui/platform/unix/qunixnativeinterface.cpp @@ -292,6 +292,11 @@ QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QVxKeyMapper); \return the seat associated with the default input device. */ +/*! + \fn struct xkb_context *QNativeInterface::QWaylandApplication::xkbContext() const + \return the XKB context associated with the application. +*/ + QT_DEFINE_NATIVE_INTERFACE(QWaylandApplication); /*! diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index e1586d2446f..c7ecd8a2816 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -64,6 +64,11 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re return touch->wl_touch(); return nullptr; } +#if QT_CONFIG(xkbcommon) + if (lowerCaseResource == "xkb_context") { + return m_integration->display()->xkbContext(); + } +#endif if (lowerCaseResource == "serial") return reinterpret_cast(quintptr(m_integration->display()->defaultInputDevice()->serial())); @@ -126,6 +131,13 @@ wl_seat *QtWaylandClient::QWaylandNativeInterface::lastInputSeat() const return nullptr; } +#if QT_CONFIG(xkbcommon) +struct xkb_context *QtWaylandClient::QWaylandNativeInterface::xkbContext() const +{ + return m_integration->display()->xkbContext(); +} +#endif + void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { QByteArray lowerCaseResource = resourceString.toLower(); diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface_p.h b/src/plugins/platforms/wayland/qwaylandnativeinterface_p.h index ce8c6bec3fd..ab2a61597d4 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface_p.h +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface_p.h @@ -62,6 +62,9 @@ public: wl_touch *touch() const override; uint lastInputSerial() const override; wl_seat *lastInputSeat() const override; +#if QT_CONFIG(xkbcommon) + struct xkb_context *xkbContext() const override; +#endif private: static void setWindowMargins(QWindow *window, const QMargins &margins);