Delay added signal and other signal bindings for synced windows until the window is actually visually shown

Makes animations of showing windows run completely and thus appear smoother

REVIEW: 103742
This commit is contained in:
Thomas Lübking 2012-01-24 17:00:40 +01:00
parent 3704163a11
commit 4d7161dd75
7 changed files with 34 additions and 10 deletions

View file

@ -2174,8 +2174,7 @@ void Client::sendSyncRequest()
void Client::removeSyncSupport()
{
if (!ready_for_painting) {
ready_for_painting = true;
addRepaintFull();
setReadyForPainting();
return;
}
syncRequest.isPending = false;

View file

@ -663,11 +663,13 @@ void Client::damageNotifyEvent(XDamageNotifyEvent* e)
#ifdef HAVE_XSYNC
if (syncRequest.isPending && isResize())
return;
if (syncRequest.counter == None) // cannot detect complete redraw, consider done now
ready_for_painting = true;
if (!ready_for_painting) { // avoid "setReadyForPainting()" function calling overhead
if (syncRequest.counter == None) // cannot detect complete redraw, consider done now
setReadyForPainting();
#else
ready_for_painting = true;
setReadyForPainting();
#endif
}
Toplevel::damageNotifyEvent(e);
}

View file

@ -373,16 +373,25 @@ void EffectsHandlerImpl::slotOpacityChanged(Toplevel *t, qreal oldOpacity)
void EffectsHandlerImpl::slotClientAdded(Client *c)
{
setupClientConnections(c);
emit windowAdded(c->effectWindow());
if (c->readyForPainting())
slotClientShown(c);
else
connect(c, SIGNAL(windowShown(KWin::Toplevel*)), SLOT(slotClientShown(KWin::Toplevel*)));
}
void EffectsHandlerImpl::slotUnmanagedAdded(Unmanaged *u)
{
{ // regardless, unmanaged windows are -yet?- not synced anyway
setupUnmanagedConnections(u);
emit windowAdded(u->effectWindow());
}
void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *c)
{
Q_ASSERT(dynamic_cast<Client*>(c));
setupClientConnections(static_cast<Client*>(c));
emit windowAdded(c->effectWindow());
}
void EffectsHandlerImpl::slotDeletedRemoved(KWin::Deleted *d)
{
emit windowDeleted(d->effectWindow());

View file

@ -184,6 +184,7 @@ public Q_SLOTS:
protected Q_SLOTS:
void slotDesktopChanged(int old);
void slotClientAdded(KWin::Client *c);
void slotClientShown(KWin::Toplevel*);
void slotUnmanagedAdded(KWin::Unmanaged *u);
void slotWindowClosed(KWin::Toplevel *c);
void slotClientActivated(KWin::Client *c);

View file

@ -1562,7 +1562,7 @@ void Client::keyPressEvent(uint key_code)
void Client::syncEvent(XSyncAlarmNotifyEvent* e)
{
if (e->alarm == syncRequest.alarm && XSyncValueEqual(e->counter_value, syncRequest.value)) {
ready_for_painting = true;
setReadyForPainting();
syncRequest.isPending = false;
if (syncRequest.failsafeTimeout)
syncRequest.failsafeTimeout->stop();
@ -1570,7 +1570,7 @@ void Client::syncEvent(XSyncAlarmNotifyEvent* e)
if (syncRequest.timeout)
syncRequest.timeout->stop();
performMoveResize();
} else
} else // setReadyForPainting does as well, but there's a small chance for resize syncs after the resize ended
addRepaintFull();
}
}

View file

@ -329,6 +329,17 @@ void Toplevel::setOpacity(double new_opacity)
}
}
void Toplevel::setReadyForPainting()
{
if (!ready_for_painting) {
ready_for_painting = true;
if (compositing()) {
addRepaintFull();
emit windowShown(this);
}
}
}
void Toplevel::deleteEffectWindow()
{
delete effect_window;

View file

@ -266,6 +266,7 @@ signals:
void geometryChanged();
void geometryShapeChanged(KWin::Toplevel* toplevel, const QRect& old);
void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted);
void windowShown(KWin::Toplevel* toplevel);
protected:
virtual ~Toplevel();
@ -280,6 +281,7 @@ protected:
void addDamageFull();
void getWmClientLeader();
void getWmClientMachine();
void setReadyForPainting();
/**
* This function fetches the opaque region from this Toplevel.