Make QOffscreenX11PlatformNativeInterface a QX11Application

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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Michal Klocek 2021-10-19 13:07:12 +02:00
parent 54576b3dd9
commit e2fc3246d2
2 changed files with 15 additions and 1 deletions

View File

@ -155,6 +155,13 @@ void *QOffscreenX11PlatformNativeInterface::nativeResourceForContext(const QByte
} }
#endif #endif
#if QT_CONFIG(xcb)
Display *QOffscreenX11PlatformNativeInterface::display() const
{
return m_connection ? reinterpret_cast<Display *>(m_connection->display()) : nullptr;
}
#endif
QOffscreenX11Connection::QOffscreenX11Connection() QOffscreenX11Connection::QOffscreenX11Connection()
{ {
XInitThreads(); XInitThreads();

View File

@ -47,6 +47,7 @@
#include <qscopedpointer.h> #include <qscopedpointer.h>
#include <qpa/qplatformopenglcontext.h> #include <qpa/qplatformopenglcontext.h>
#include <QtGui/qguiapplication.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -54,6 +55,9 @@ class QOffscreenX11Connection;
class QOffscreenX11Info; class QOffscreenX11Info;
class QOffscreenX11PlatformNativeInterface : public QOffscreenPlatformNativeInterface class QOffscreenX11PlatformNativeInterface : public QOffscreenPlatformNativeInterface
#if QT_CONFIG(xcb)
, public QNativeInterface::QX11Application
#endif
{ {
public: public:
QOffscreenX11PlatformNativeInterface(QOffscreenIntegration *integration); QOffscreenX11PlatformNativeInterface(QOffscreenIntegration *integration);
@ -63,7 +67,10 @@ public:
#if !defined(QT_NO_OPENGL) && QT_CONFIG(xcb_glx_plugin) #if !defined(QT_NO_OPENGL) && QT_CONFIG(xcb_glx_plugin)
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override; void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override;
#endif #endif
#if QT_CONFIG(xcb)
Display *display() const override;
xcb_connection_t *connection() const override { return nullptr; };
#endif
QScopedPointer<QOffscreenX11Connection> m_connection; QScopedPointer<QOffscreenX11Connection> m_connection;
}; };