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 <davidedmundson@kde.org>
This commit is contained in:
Dmitry Kazakov 2025-05-28 12:59:25 +02:00
parent 1b4abf645a
commit b5147dca11
5 changed files with 29 additions and 1 deletions

View File

@ -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
)

View File

@ -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

View File

@ -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);
/*!

View File

@ -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();

View File

@ -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);