diff --git a/src/scripting/thumbnailitem.cpp b/src/scripting/thumbnailitem.cpp index 61bdc35514..f272c2b16d 100644 --- a/src/scripting/thumbnailitem.cpp +++ b/src/scripting/thumbnailitem.cpp @@ -211,7 +211,9 @@ QSGNode *ThumbnailItemBase::updatePaintNode(QSGNode *oldNode, QQuickItem::Update if (m_offscreenTexture) { m_provider->setTexture(m_offscreenTexture); } else { - m_provider->setTexture(window()->createTextureFromImage(fallbackImage())); + const QImage placeholderImage = fallbackImage(); + m_provider->setTexture(window()->createTextureFromImage(placeholderImage)); + m_devicePixelRatio = placeholderImage.devicePixelRatio(); } QSGImageNode *node = static_cast(oldNode); @@ -226,7 +228,7 @@ QSGNode *ThumbnailItemBase::updatePaintNode(QSGNode *oldNode, QQuickItem::Update node->setTextureCoordinatesTransform(QSGImageNode::NoTransform); } - const QSizeF size = QSizeF(node->texture()->textureSize()) + const QSizeF size = QSizeF(node->texture()->textureSize() / m_devicePixelRatio) .scaled(boundingRect().size(), Qt::KeepAspectRatio); const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2; const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2; @@ -311,7 +313,7 @@ void WindowThumbnailItem::setClient(AbstractClient *client) QImage WindowThumbnailItem::fallbackImage() const { if (m_client) { - return m_client->icon().pixmap(boundingRect().size().toSize()).toImage(); + return m_client->icon().pixmap(window(), boundingRect().size().toSize()).toImage(); } return QImage(); } @@ -337,6 +339,9 @@ void WindowThumbnailItem::updateOffscreenTexture() textureSize.setHeight(sourceSize().height()); } + m_devicePixelRatio = window()->devicePixelRatio(); + textureSize *= m_devicePixelRatio; + if (!m_offscreenTexture || m_offscreenTexture->size() != textureSize) { m_offscreenTexture.reset(new GLTexture(GL_RGBA8, textureSize)); m_offscreenTexture->setFilter(GL_LINEAR); @@ -417,6 +422,9 @@ void DesktopThumbnailItem::updateOffscreenTexture() textureSize.setHeight(sourceSize().height()); } + m_devicePixelRatio = window()->devicePixelRatio(); + textureSize *= m_devicePixelRatio; + if (!m_offscreenTexture || m_offscreenTexture->size() != textureSize) { m_offscreenTexture.reset(new GLTexture(GL_RGBA8, textureSize)); m_offscreenTexture->setFilter(GL_LINEAR); diff --git a/src/scripting/thumbnailitem.h b/src/scripting/thumbnailitem.h index b53b16e325..363d79341a 100644 --- a/src/scripting/thumbnailitem.h +++ b/src/scripting/thumbnailitem.h @@ -77,6 +77,7 @@ protected: QSharedPointer m_offscreenTexture; QScopedPointer m_offscreenTarget; GLsync m_acquireFence = 0; + qreal m_devicePixelRatio = 1; private: void handleCompositingToggled();