Use new nativeInterface() API to get EGL/GLX contexts with Qt6
This commit is contained in:
parent
1679452f41
commit
4b810833b5
2 changed files with 25 additions and 0 deletions
|
@ -19,7 +19,9 @@
|
||||||
#include "x11_platform.h"
|
#include "x11_platform.h"
|
||||||
|
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include <QtPlatformHeaders/QEGLNativeContext>
|
#include <QtPlatformHeaders/QEGLNativeContext>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,7 @@ void EglBackend::init()
|
||||||
EGLContext shareContext = EGL_NO_CONTEXT;
|
EGLContext shareContext = EGL_NO_CONTEXT;
|
||||||
if (qtShareContext) {
|
if (qtShareContext) {
|
||||||
qDebug(KWIN_X11STANDALONE) << "Global share context format:" << qtShareContext->format();
|
qDebug(KWIN_X11STANDALONE) << "Global share context format:" << qtShareContext->format();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
const QVariant nativeHandle = qtShareContext->nativeHandle();
|
const QVariant nativeHandle = qtShareContext->nativeHandle();
|
||||||
if (!nativeHandle.canConvert<QEGLNativeContext>()) {
|
if (!nativeHandle.canConvert<QEGLNativeContext>()) {
|
||||||
setFailed(QStringLiteral("Invalid QOpenGLContext::globalShareContext()"));
|
setFailed(QStringLiteral("Invalid QOpenGLContext::globalShareContext()"));
|
||||||
|
@ -70,6 +73,16 @@ void EglBackend::init()
|
||||||
shareContext = handle.context();
|
shareContext = handle.context();
|
||||||
shareDisplay = handle.display();
|
shareDisplay = handle.display();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const auto nativeHandle = qtShareContext->nativeInterface<QNativeInterface::QEGLContext>();
|
||||||
|
if (nativeHandle) {
|
||||||
|
shareContext = nativeHandle->nativeContext();
|
||||||
|
shareDisplay = nativeHandle->display();
|
||||||
|
} else {
|
||||||
|
setFailed(QStringLiteral("Invalid QOpenGLContext::globalShareContext()"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (shareContext == EGL_NO_CONTEXT) {
|
if (shareContext == EGL_NO_CONTEXT) {
|
||||||
setFailed(QStringLiteral("QOpenGLContext::globalShareContext() is required"));
|
setFailed(QStringLiteral("QOpenGLContext::globalShareContext() is required"));
|
||||||
|
|
|
@ -43,7 +43,9 @@
|
||||||
#else
|
#else
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#endif
|
#endif
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include <QtPlatformHeaders/QGLXNativeContext>
|
#include <QtPlatformHeaders/QGLXNativeContext>
|
||||||
|
#endif
|
||||||
// system
|
// system
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -322,6 +324,7 @@ bool GlxBackend::initRenderingContext()
|
||||||
GLXContext globalShareContext = nullptr;
|
GLXContext globalShareContext = nullptr;
|
||||||
if (qtGlobalShareContext) {
|
if (qtGlobalShareContext) {
|
||||||
qDebug(KWIN_X11STANDALONE) << "Global share context format:" << qtGlobalShareContext->format();
|
qDebug(KWIN_X11STANDALONE) << "Global share context format:" << qtGlobalShareContext->format();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
const QVariant nativeHandle = qtGlobalShareContext->nativeHandle();
|
const QVariant nativeHandle = qtGlobalShareContext->nativeHandle();
|
||||||
if (!nativeHandle.canConvert<QGLXNativeContext>()) {
|
if (!nativeHandle.canConvert<QGLXNativeContext>()) {
|
||||||
qCDebug(KWIN_X11STANDALONE) << "Invalid QOpenGLContext::globalShareContext()";
|
qCDebug(KWIN_X11STANDALONE) << "Invalid QOpenGLContext::globalShareContext()";
|
||||||
|
@ -330,6 +333,15 @@ bool GlxBackend::initRenderingContext()
|
||||||
QGLXNativeContext handle = qvariant_cast<QGLXNativeContext>(nativeHandle);
|
QGLXNativeContext handle = qvariant_cast<QGLXNativeContext>(nativeHandle);
|
||||||
globalShareContext = handle.context();
|
globalShareContext = handle.context();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const auto nativeHandle = qtGlobalShareContext->nativeInterface<QNativeInterface::QGLXContext>();
|
||||||
|
if (nativeHandle) {
|
||||||
|
globalShareContext = nativeHandle->nativeContext();
|
||||||
|
} else {
|
||||||
|
qCDebug(KWIN_X11STANDALONE) << "Invalid QOpenGLContext::globalShareContext()";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!globalShareContext) {
|
if (!globalShareContext) {
|
||||||
qCWarning(KWIN_X11STANDALONE) << "QOpenGLContext::globalShareContext() is required";
|
qCWarning(KWIN_X11STANDALONE) << "QOpenGLContext::globalShareContext() is required";
|
||||||
|
|
Loading…
Reference in a new issue