summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-03 23:09:27 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-06 15:09:39 +0200
commitf5203eeada83bbe8e316a5188e24636af3e83b09 (patch)
tree12230fb8072fe9a964cf9a1dd4982ad7d85acb94 /src/plugins/platforms/xcb
parente158502e332e482267d8585b791f5e2a7f82888c (diff)
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<QX11Application>()) 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 <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h11
2 files changed, 15 insertions, 11 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 95c552a468..55633aade7 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -118,7 +118,7 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
case RootWindow:
result = rootWindow();
break;
- case Display:
+ case XDisplay:
result = display();
break;
case AtspiBus:
@@ -155,7 +155,7 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
switch (resourceType(lowerCaseResource)) {
- case Display:
+ case XDisplay:
#if QT_CONFIG(xcb_xlib)
result = xcbScreen->connection()->xlib_display();
#endif
@@ -203,7 +203,7 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
return result;
switch (resourceType(lowerCaseResource)) {
- case Display:
+ case XDisplay:
result = displayForWindow(window);
break;
case Connection:
@@ -365,18 +365,17 @@ void *QXcbNativeInterface::rootWindow()
return nullptr;
}
-void *QXcbNativeInterface::display()
+Display *QXcbNativeInterface::display() const
{
#if QT_CONFIG(xcb_xlib)
QXcbIntegration *integration = QXcbIntegration::instance();
- QXcbConnection *connection = integration->connection();
- if (connection)
- return connection->xlib_display();
+ if (QXcbConnection *connection = integration->connection())
+ return reinterpret_cast<Display *>(connection->xlib_display());
#endif
return nullptr;
}
-void *QXcbNativeInterface::connection()
+xcb_connection_t *QXcbNativeInterface::connection() const
{
QXcbIntegration *integration = QXcbIntegration::instance();
return integration->connection()->xcb_connection();
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 4656f46be5..5508d57679 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -45,6 +45,8 @@
#include <QtCore/QRect>
+#include <QtGui/qguiapplication.h>
+
#include "qxcbexport.h"
#include "qxcbconnection.h"
@@ -54,11 +56,12 @@ class QXcbScreen;
class QXcbNativeInterfaceHandler;
class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
+ , public QNativeInterface::QX11Application
{
Q_OBJECT
public:
enum ResourceType {
- Display,
+ XDisplay,
Connection,
Screen,
AppTime,
@@ -109,9 +112,11 @@ public:
void *startupId();
void *x11Screen();
void *rootWindow();
- void *display();
+
+ Display *display() const override;
+ xcb_connection_t *connection() const override;
+
void *atspiBus();
- void *connection();
static void setStartupId(const char *);
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);