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.
This commit is contained in:
Martin Gräßlin 2011-11-29 07:13:26 +01:00
parent cc6fa14c9b
commit b57ef77bf7
4 changed files with 17 additions and 2 deletions

View file

@ -419,8 +419,8 @@ void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quad
} else { } else {
thumbMask |= PAINT_WINDOW_TRANSLUCENT; thumbMask |= PAINT_WINDOW_TRANSLUCENT;
} }
if (x < wImpl->x() || x + size.width() > wImpl->x() + wImpl->width() || if (item->isClip() && (x < wImpl->x() || x + size.width() > wImpl->x() + wImpl->width() ||
y < wImpl->y() || y + size.height() > wImpl->y() + wImpl->height()) { y < wImpl->y() || y + size.height() > wImpl->y() + wImpl->height())) {
// don't render windows outside the containing window. // don't render windows outside the containing window.
// TODO: improve by spliting out the window quads which do not fit // TODO: improve by spliting out the window quads which do not fit
continue; continue;

View file

@ -78,6 +78,7 @@ Item {
wId: windowId wId: windowId
width: parent.width - closeButtonContainer.width - 20 width: parent.width - closeButtonContainer.width - 20
height: thumbnailListView.height - 40 height: thumbnailListView.height - 40
clip: false
anchors.centerIn: parent anchors.centerIn: parent
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent

View file

@ -35,6 +35,7 @@ namespace KWin
ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent) ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
: QDeclarativeItem(parent) : QDeclarativeItem(parent)
, m_wId(0) , m_wId(0)
, m_clip(true)
, m_parent(QWeakPointer<EffectWindowImpl>()) , m_parent(QWeakPointer<EffectWindowImpl>())
{ {
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents); setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
@ -81,6 +82,12 @@ void ThumbnailItem::setWId(qulonglong wId)
emit wIdChanged(wId); emit wIdChanged(wId);
} }
void ThumbnailItem::setClip(bool clip)
{
m_clip = clip;
emit clipChanged(clip);
}
void ThumbnailItem::effectWindowAdded() void ThumbnailItem::effectWindowAdded()
{ {
// the window might be added before the EffectWindow is created // the window might be added before the EffectWindow is created

View file

@ -34,6 +34,7 @@ class ThumbnailItem : public QDeclarativeItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true) 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: public:
ThumbnailItem(QDeclarativeItem *parent = 0); ThumbnailItem(QDeclarativeItem *parent = 0);
virtual ~ThumbnailItem(); virtual ~ThumbnailItem();
@ -42,15 +43,21 @@ public:
return m_wId; return m_wId;
} }
void setWId(qulonglong 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); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Q_SIGNALS: Q_SIGNALS:
void wIdChanged(qulonglong wid); void wIdChanged(qulonglong wid);
void clipChanged(bool clipped);
private Q_SLOTS: private Q_SLOTS:
void init(); void init();
void effectWindowAdded(); void effectWindowAdded();
private: private:
void findParentEffectWindow(); void findParentEffectWindow();
qulonglong m_wId; qulonglong m_wId;
bool m_clip;
QWeakPointer<EffectWindowImpl> m_parent; QWeakPointer<EffectWindowImpl> m_parent;
}; };