From f5203eeada83bbe8e316a5188e24636af3e83b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 3 Aug 2021 23:09:27 +0200 Subject: Add native interface for X11 application, exposing display and connection The major use-case of the now private QX11Info from Qt X11 Extras was getting hold of the Xlib display and XCB connection, for example in KDE: https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=QX11Info A new native interface for QGuiApplication has now been added that exposes these two properties, e.g.: if (auto *x11App = app.nativeInterface()) qDebug() << x11App->display() << x11App->connection(); To avoid type clashes one of the enum values of QXcbNativeInterface's ResourceType had to be renamed. Pick-to: 6.2 Task-number: QTBUG-93633 Change-Id: I2e366a2bb88bd3965ac6172ad000ae32209f43e7 Reviewed-by: Lars Knoll --- src/gui/platform/unix/qunixnativeinterface.cpp | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/gui/platform/unix/qunixnativeinterface.cpp') diff --git a/src/gui/platform/unix/qunixnativeinterface.cpp b/src/gui/platform/unix/qunixnativeinterface.cpp index 4febe69d91e..22bbc555f10 100644 --- a/src/gui/platform/unix/qunixnativeinterface.cpp +++ b/src/gui/platform/unix/qunixnativeinterface.cpp @@ -179,6 +179,36 @@ QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QXcbScreen); QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QXcbWindow); +/*! + \class QNativeInterface::QX11Application + \since 6.0 + \brief Native interface to an X11 application. + + Accessed through QGuiApplication::nativeInterface(). + + \inmodule QtGui + \ingroup native-interfaces + \ingroup native-interfaces-qguiapplication +*/ + +/*! + \fn Display *QNativeInterface::QX11Application::display() const + + \return the X display of the application, for use with Xlib. + + \sa connection() +*/ + +/*! + \fn xcb_connection_t *QNativeInterface::QX11Application::connection() const + + \return the X connection of the application, for use with XCB. + + \sa display() +*/ + +QT_DEFINE_NATIVE_INTERFACE(QX11Application); + #endif // QT_CONFIG(xcb) #if QT_CONFIG(vsp2) -- cgit v1.2.3