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.
icc-effect-5.14.5
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 {
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;

View File

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

View File

@ -35,6 +35,7 @@ namespace KWin
ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
: QDeclarativeItem(parent)
, m_wId(0)
, m_clip(true)
, m_parent(QWeakPointer<EffectWindowImpl>())
{
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

View File

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