Add thumbnailAvailable property to PlasmaCore.WindowThumbnail

This property tells us whether a thumbnail is actually being rendered or it has
fallen back to the window icon

REVIEW: 120946
BUG: 336524
This commit is contained in:
Kai Uwe Broulik 2014-11-03 10:11:32 +01:00
parent 481e796e67
commit ce1ba8a687
2 changed files with 22 additions and 0 deletions

View File

@ -65,6 +65,7 @@ WindowThumbnail::WindowThumbnail(QQuickItem *parent)
, m_xcb(false)
, m_winId(0)
, m_paintedSize(QSizeF())
, m_thumbnailAvailable(false)
, m_damaged(false)
, m_depth(0)
#if HAVE_XCB_COMPOSITE
@ -151,6 +152,11 @@ qreal WindowThumbnail::paintedHeight() const
return m_paintedSize.height();
}
bool WindowThumbnail::thumbnailAvailable() const
{
return m_thumbnailAvailable;
}
QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
{
Q_UNUSED(updatePaintNodeData)
@ -350,6 +356,7 @@ void WindowThumbnail::windowToTexture(WindowTextureNode *textureNode)
if (m_pixmap == XCB_PIXMAP_NONE) {
// create above failed
iconToTexture(textureNode);
setThumbnailAvailable(false);
return;
}
bool fallbackToIcon = true;
@ -366,6 +373,7 @@ void WindowThumbnail::windowToTexture(WindowTextureNode *textureNode)
// just for safety to not crash
iconToTexture(textureNode);
}
setThumbnailAvailable(!fallbackToIcon);
textureNode->markDirty(QSGNode::DirtyForceUpdate);
#else
iconToTexture(textureNode);
@ -615,4 +623,12 @@ void WindowThumbnail::discardPixmap()
#endif
}
void WindowThumbnail::setThumbnailAvailable(bool thumbnailAvailable)
{
if (m_thumbnailAvailable != thumbnailAvailable) {
m_thumbnailAvailable = thumbnailAvailable;
emit thumbnailAvailableChanged();
}
}
} // namespace

View File

@ -78,6 +78,7 @@ class WindowThumbnail : public QQuickItem, public QAbstractNativeEventFilter
Q_PROPERTY(uint winId READ winId WRITE setWinId NOTIFY winIdChanged)
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
Q_PROPERTY(bool thumbnailAvailable READ thumbnailAvailable NOTIFY thumbnailAvailableChanged)
public:
WindowThumbnail(QQuickItem *parent = 0);
@ -90,10 +91,12 @@ public:
qreal paintedWidth() const;
qreal paintedHeight() const;
bool thumbnailAvailable() const;
Q_SIGNALS:
void winIdChanged();
void paintedSizeChanged();
void thumbnailAvailableChanged();
private:
void iconToTexture(WindowTextureNode *textureNode);
@ -102,9 +105,12 @@ private:
void stopRedirecting();
void resetDamaged();
void discardPixmap();
void setThumbnailAvailable(bool thumbnailAvailable);
bool m_xcb;
uint32_t m_winId;
QSizeF m_paintedSize;
bool m_thumbnailAvailable;
bool m_damaged;
int m_depth;
#if HAVE_XCB_COMPOSITE