[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.
This commit is contained in:
David Edmundson 2022-09-27 11:18:06 +01:00
parent 1a87e9c9ac
commit 50b4e988a4
2 changed files with 9 additions and 2 deletions

View file

@ -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;
}

View file

@ -87,6 +87,7 @@ private:
void destroyOffscreenTexture();
void updateImplicitSize();
void updateFrameRenderingConnection();
static bool useGlThumbnails();
QSize m_sourceSize;
QUuid m_wId;