From e2fc3246d24e2b3a64ec2005e51efae88cbdc32e Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 19 Oct 2021 13:07:12 +0200 Subject: [PATCH] Make QOffscreenX11PlatformNativeInterface a QX11Application MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it possible to use new native interface QX11Application with offscreen plugin in case of x11, which technically is x11 application without xcb connection. This change is motivated by use of new native interface in webengine, where offscreen plugin is used for some tests. Pick-to: 6.2 Change-Id: Ic2ed5b39573062feaa1e8985962d5d9327b371d7 Reviewed-by: Tor Arne Vestbø --- .../platforms/offscreen/qoffscreenintegration_x11.cpp | 7 +++++++ .../platforms/offscreen/qoffscreenintegration_x11.h | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index 3c2fdb1f0f..0bb19bc4f6 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -155,6 +155,13 @@ void *QOffscreenX11PlatformNativeInterface::nativeResourceForContext(const QByte } #endif +#if QT_CONFIG(xcb) +Display *QOffscreenX11PlatformNativeInterface::display() const +{ + return m_connection ? reinterpret_cast(m_connection->display()) : nullptr; +} +#endif + QOffscreenX11Connection::QOffscreenX11Connection() { XInitThreads(); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h index afd30d7b4b..35c91d47d8 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.h @@ -47,6 +47,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -54,6 +55,9 @@ class QOffscreenX11Connection; class QOffscreenX11Info; class QOffscreenX11PlatformNativeInterface : public QOffscreenPlatformNativeInterface +#if QT_CONFIG(xcb) + , public QNativeInterface::QX11Application +#endif { public: QOffscreenX11PlatformNativeInterface(QOffscreenIntegration *integration); @@ -63,7 +67,10 @@ public: #if !defined(QT_NO_OPENGL) && QT_CONFIG(xcb_glx_plugin) void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override; #endif - +#if QT_CONFIG(xcb) + Display *display() const override; + xcb_connection_t *connection() const override { return nullptr; }; +#endif QScopedPointer m_connection; };