From 50b4e988a4794be6fd526eb3e4b1626e17f19637 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 27 Sep 2022 11:18:06 +0100 Subject: [PATCH] [windowthumbnails] Guard against software QtQuick backend If we are using the software renderer QQuickWindow::createTextureFromNativeObject returns null. We already checking for kwin using GL compositing so we can expand to check QtQuick's usage. --- src/scripting/windowthumbnailitem.cpp | 10 ++++++++-- src/scripting/windowthumbnailitem.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scripting/windowthumbnailitem.cpp b/src/scripting/windowthumbnailitem.cpp index ba639f74d1..ba25ff202b 100644 --- a/src/scripting/windowthumbnailitem.cpp +++ b/src/scripting/windowthumbnailitem.cpp @@ -164,11 +164,17 @@ void WindowThumbnailItem::updateFrameRenderingConnection() return; } - if (Compositor::self()->backend()->compositingType() == OpenGLCompositing) { + if (useGlThumbnails()) { m_frameRenderingConnection = connect(Compositor::self()->scene(), &Scene::preFrameRender, this, &WindowThumbnailItem::updateOffscreenTexture); } } +bool WindowThumbnailItem::useGlThumbnails() +{ + static bool qtQuickIsSoftware = QStringList({QStringLiteral("software"), QStringLiteral("softwarecontext")}).contains(QQuickWindow::sceneGraphBackend()); + return Compositor::self()->backend()->compositingType() == OpenGLCompositing && !qtQuickIsSoftware; +} + QSize WindowThumbnailItem::sourceSize() const { return m_sourceSize; @@ -188,7 +194,7 @@ void WindowThumbnailItem::destroyOffscreenTexture() if (!Compositor::compositing()) { return; } - if (Compositor::self()->backend()->compositingType() != OpenGLCompositing) { + if (!useGlThumbnails()) { return; } diff --git a/src/scripting/windowthumbnailitem.h b/src/scripting/windowthumbnailitem.h index 73bf7ee373..251fe03c8c 100644 --- a/src/scripting/windowthumbnailitem.h +++ b/src/scripting/windowthumbnailitem.h @@ -87,6 +87,7 @@ private: void destroyOffscreenTexture(); void updateImplicitSize(); void updateFrameRenderingConnection(); + static bool useGlThumbnails(); QSize m_sourceSize; QUuid m_wId;