From b57ef77bf7bf9e8afa55343d74dfc1d650aaf16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 29 Nov 2011 07:13:26 +0100 Subject: [PATCH] Adding a clip property to the ThumbnailItem By default clip is enabled. This means that if the thumbnail would overlap the "parent" window, it does not get rendered at all. If set to false it will always be rendered. This is required for window strip where the complete screen width is used, so overlap does not matter. --- scene.cpp | 4 ++-- tabbox/qml/window_strip.qml | 1 + thumbnailitem.cpp | 7 +++++++ thumbnailitem.h | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scene.cpp b/scene.cpp index 81ca9378a8..82935c2e90 100644 --- a/scene.cpp +++ b/scene.cpp @@ -419,8 +419,8 @@ void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quad } else { thumbMask |= PAINT_WINDOW_TRANSLUCENT; } - if (x < wImpl->x() || x + size.width() > wImpl->x() + wImpl->width() || - y < wImpl->y() || y + size.height() > wImpl->y() + wImpl->height()) { + if (item->isClip() && (x < wImpl->x() || x + size.width() > wImpl->x() + wImpl->width() || + y < wImpl->y() || y + size.height() > wImpl->y() + wImpl->height())) { // don't render windows outside the containing window. // TODO: improve by spliting out the window quads which do not fit continue; diff --git a/tabbox/qml/window_strip.qml b/tabbox/qml/window_strip.qml index 3ce0f49cd4..801bc61158 100644 --- a/tabbox/qml/window_strip.qml +++ b/tabbox/qml/window_strip.qml @@ -78,6 +78,7 @@ Item { wId: windowId width: parent.width - closeButtonContainer.width - 20 height: thumbnailListView.height - 40 + clip: false anchors.centerIn: parent MouseArea { anchors.fill: parent diff --git a/thumbnailitem.cpp b/thumbnailitem.cpp index 8c209833f0..73441a059f 100644 --- a/thumbnailitem.cpp +++ b/thumbnailitem.cpp @@ -35,6 +35,7 @@ namespace KWin ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent) : QDeclarativeItem(parent) , m_wId(0) + , m_clip(true) , m_parent(QWeakPointer()) { setFlags(flags() & ~QGraphicsItem::ItemHasNoContents); @@ -81,6 +82,12 @@ void ThumbnailItem::setWId(qulonglong wId) emit wIdChanged(wId); } +void ThumbnailItem::setClip(bool clip) +{ + m_clip = clip; + emit clipChanged(clip); +} + void ThumbnailItem::effectWindowAdded() { // the window might be added before the EffectWindow is created diff --git a/thumbnailitem.h b/thumbnailitem.h index 2ff354672f..8d39f5fc26 100644 --- a/thumbnailitem.h +++ b/thumbnailitem.h @@ -34,6 +34,7 @@ class ThumbnailItem : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true) + Q_PROPERTY(bool clip READ isClip WRITE setClip NOTIFY clipChanged SCRIPTABLE true) public: ThumbnailItem(QDeclarativeItem *parent = 0); virtual ~ThumbnailItem(); @@ -42,15 +43,21 @@ public: return m_wId; } void setWId(qulonglong wId); + bool isClip() const { + return m_clip; + } + void setClip(bool clip); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); Q_SIGNALS: void wIdChanged(qulonglong wid); + void clipChanged(bool clipped); private Q_SLOTS: void init(); void effectWindowAdded(); private: void findParentEffectWindow(); qulonglong m_wId; + bool m_clip; QWeakPointer m_parent; };