Update cached Shadow information on size changes
In order to notice when the geometry changes a new signal is added to toplevel and both Unmanaged and Client connect all their signals which are emitted whenever the geometry changes in some way to this new signal. Shadow connects to the signal and updates the quads and region whenever the size changes.
This commit is contained in:
parent
24f36b7fae
commit
7287019050
5 changed files with 30 additions and 3 deletions
|
@ -194,6 +194,10 @@ Client::Client(Workspace* ws)
|
|||
ready_for_painting = false; // wait for first damage or sync reply
|
||||
#endif
|
||||
|
||||
connect(this, SIGNAL(clientGeometryShapeChanged(KWin::Client*,QRect)), SIGNAL(geometryChanged()));
|
||||
connect(this, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), SIGNAL(geometryChanged()));
|
||||
connect(this, SIGNAL(clientStepUserMovedResized(KWin::Client*,QRect)), SIGNAL(geometryChanged()));
|
||||
|
||||
// SELI TODO: Initialize xsizehints??
|
||||
}
|
||||
|
||||
|
|
22
shadow.cpp
22
shadow.cpp
|
@ -31,7 +31,9 @@ namespace KWin
|
|||
|
||||
Shadow::Shadow(Toplevel *toplevel)
|
||||
: m_topLevel(toplevel)
|
||||
, m_cachedSize(toplevel->geometry().size())
|
||||
{
|
||||
connect(m_topLevel, SIGNAL(geometryChanged()), SLOT(geometryChanged()));
|
||||
}
|
||||
|
||||
Shadow::~Shadow()
|
||||
|
@ -99,14 +101,18 @@ bool Shadow::init(const QVector< long > &data)
|
|||
m_rightOffset = data[ShadowElementsCount+1];
|
||||
m_bottomOffset = data[ShadowElementsCount+2];
|
||||
m_leftOffset = data[ShadowElementsCount+3];
|
||||
// prepare shadow region
|
||||
updateShadowRegion();
|
||||
buildQuads();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shadow::updateShadowRegion()
|
||||
{
|
||||
const QRect topRect(0, - m_topOffset, m_topLevel->width(), m_topOffset);
|
||||
const QRect rightRect(m_topLevel->width(), - m_topOffset, m_rightOffset, m_topLevel->height() + m_topOffset + m_bottomOffset);
|
||||
const QRect bottomRect(0, m_topLevel->height(), m_topLevel->width(), m_bottomOffset);
|
||||
const QRect leftRect(- m_leftOffset, - m_topOffset, m_leftOffset, m_topLevel->height() + m_topOffset + m_bottomOffset);
|
||||
m_shadowRegion = QRegion(topRect).united(rightRect).united(bottomRect).united(leftRect);
|
||||
buildQuads();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shadow::buildQuads()
|
||||
|
@ -184,6 +190,16 @@ bool Shadow::updateShadow()
|
|||
void Shadow::setToplevel(Toplevel *topLevel)
|
||||
{
|
||||
m_topLevel = topLevel;
|
||||
connect(m_topLevel, SIGNAL(geometryChanged()), SLOT(geometryChanged()));
|
||||
}
|
||||
void Shadow::geometryChanged()
|
||||
{
|
||||
if (m_cachedSize == m_topLevel->geometry().size()) {
|
||||
return;
|
||||
}
|
||||
m_cachedSize = m_topLevel->geometry().size();
|
||||
updateShadowRegion();
|
||||
buildQuads();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
5
shadow.h
5
shadow.h
|
@ -92,6 +92,9 @@ public:
|
|||
**/
|
||||
void setToplevel(Toplevel *toplevel);
|
||||
|
||||
public Q_SLOTS:
|
||||
void geometryChanged();
|
||||
|
||||
protected:
|
||||
Shadow(Toplevel *toplevel);
|
||||
enum ShadowElements {
|
||||
|
@ -121,6 +124,7 @@ protected:
|
|||
return m_leftOffset;
|
||||
};
|
||||
virtual void buildQuads();
|
||||
void updateShadowRegion();
|
||||
|
||||
private:
|
||||
static QVector<long> readX11ShadowProperty(WId id);
|
||||
|
@ -136,6 +140,7 @@ private:
|
|||
// caches
|
||||
QRegion m_shadowRegion;
|
||||
WindowQuadList m_shadowQuads;
|
||||
QSize m_cachedSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ signals:
|
|||
void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity);
|
||||
void damaged(KWin::Toplevel* toplevel, const QRect& damage);
|
||||
void propertyNotify(KWin::Toplevel* toplevel, long a);
|
||||
void geometryChanged();
|
||||
|
||||
protected:
|
||||
virtual ~Toplevel();
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace KWin
|
|||
Unmanaged::Unmanaged(Workspace* ws)
|
||||
: Toplevel(ws)
|
||||
{
|
||||
connect(this, SIGNAL(unmanagedGeometryShapeChanged(KWin::Unmanaged*,QRect)), SIGNAL(geometryChanged()));
|
||||
}
|
||||
|
||||
Unmanaged::~Unmanaged()
|
||||
|
|
Loading…
Reference in a new issue