summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Kazakov <[email protected]>2025-05-28 12:59:25 +0200
committerDmitry Kazakov <[email protected]>2025-09-12 13:59:48 +0200
commitb5147dca11ea67f72c8292d95f7de7f6853b11fc (patch)
tree95460ed390dd2e047681f6e5e46e8fa28cf12398
parent1b4abf645afe3dc137dbdb6e9e27b85db9403cac (diff)
Add QWaylandApplication::xkbContext()
It is necessary for the apps that want to manually parse the stream of events from wl_keyborad. Change-Id: I8229ae6e43640d0e7b9597f5f7b35cba59db0f64 Reviewed-by: David Edmundson <[email protected]>
-rw-r--r--src/gui/configure.cmake2
-rw-r--r--src/gui/kernel/qguiapplication_platform.h8
-rw-r--r--src/gui/platform/unix/qunixnativeinterface.cpp5
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.cpp12
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface_p.h3
5 files changed, 29 insertions, 1 deletions
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<void *>(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);