[libkwineffects] Add signals windowShown and windowHidden to EffectsHandler

Summary:
This allows effects to animate when a window is shown again and when
a window gets hidden but not yet closed/destroyed. This situation
happens on X11 for e.g. auto hiding panels and on Wayland for pretty
much any window which properly unmaps (windowHidden) prior to destroy.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2084
icc-effect-5.14.5
Martin Gräßlin 2016-07-04 15:37:30 +02:00
parent a35ffa93d7
commit 5ee958ca7e
3 changed files with 49 additions and 0 deletions

View File

@ -86,6 +86,10 @@ void TestShellClient::testMapUnmapMap()
// this test verifies that mapping a previously mapped window works correctly
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
QSignalSpy effectsWindowShownSpy(effects, &EffectsHandler::windowShown);
QVERIFY(effectsWindowShownSpy.isValid());
QSignalSpy effectsWindowHiddenSpy(effects, &EffectsHandler::windowHidden);
QVERIFY(effectsWindowHiddenSpy.isValid());
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
@ -101,6 +105,7 @@ void TestShellClient::testMapUnmapMap()
QCOMPARE(client->isHiddenInternal(), false);
QCOMPARE(client->readyForPainting(), true);
QCOMPARE(workspace()->activeClient(), client);
QVERIFY(effectsWindowShownSpy.isEmpty());
// now unmap
QSignalSpy hiddenSpy(client, &ShellClient::windowHidden);
@ -114,6 +119,8 @@ void TestShellClient::testMapUnmapMap()
QCOMPARE(client->isHiddenInternal(), true);
QVERIFY(windowClosedSpy.isEmpty());
QVERIFY(!workspace()->activeClient());
QCOMPARE(effectsWindowHiddenSpy.count(), 1);
QCOMPARE(effectsWindowHiddenSpy.first().first().value<EffectWindow*>(), client->effectWindow());
QSignalSpy windowShownSpy(client, &ShellClient::windowShown);
QVERIFY(windowShownSpy.isValid());
@ -122,19 +129,28 @@ void TestShellClient::testMapUnmapMap()
QVERIFY(windowShownSpy.wait());
QCOMPARE(windowShownSpy.count(), 1);
QCOMPARE(clientAddedSpy.count(), 1);
QCOMPARE(client->readyForPainting(), true);
QCOMPARE(client->isHiddenInternal(), false);
QCOMPARE(workspace()->activeClient(), client);
QCOMPARE(effectsWindowShownSpy.count(), 1);
QCOMPARE(effectsWindowShownSpy.first().first().value<EffectWindow*>(), client->effectWindow());
// let's unmap again
surface->attachBuffer(Buffer::Ptr());
surface->commit(Surface::CommitFlag::None);
QVERIFY(hiddenSpy.wait());
QCOMPARE(hiddenSpy.count(), 2);
QCOMPARE(client->readyForPainting(), true);
QCOMPARE(client->isHiddenInternal(), true);
QVERIFY(windowClosedSpy.isEmpty());
QCOMPARE(effectsWindowHiddenSpy.count(), 2);
QCOMPARE(effectsWindowHiddenSpy.last().first().value<EffectWindow*>(), client->effectWindow());
shellSurface.reset();
surface.reset();
QVERIFY(windowClosedSpy.wait());
QCOMPARE(windowClosedSpy.count(), 1);
QCOMPARE(effectsWindowHiddenSpy.count(), 2);
}
void TestShellClient::testDesktopPresenceChanged()

View File

@ -386,6 +386,16 @@ void EffectsHandlerImpl::setupAbstractClientConnections(AbstractClient* c)
connect(c, &AbstractClient::modalChanged, this, &EffectsHandlerImpl::slotClientModalityChanged);
connect(c, &AbstractClient::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
connect(c, &AbstractClient::damaged, this, &EffectsHandlerImpl::slotWindowDamaged);
connect(c, &AbstractClient::windowShown, this,
[this](Toplevel *c) {
emit windowShown(c->effectWindow());
}
);
connect(c, &AbstractClient::windowHidden, this,
[this](Toplevel *c) {
emit windowHidden(c->effectWindow());
}
);
}
void EffectsHandlerImpl::setupClientConnections(Client* c)

View File

@ -1430,6 +1430,29 @@ Q_SIGNALS:
**/
void virtualScreenGeometryChanged();
/**
* The window @p w gets shown again. The window was previously
* initially shown with @link{windowAdded} and hidden with @link{windowHidden}.
*
* @see windowHidden
* @see windowAdded
* @since 5.8
**/
void windowShown(KWin::EffectWindow *w);
/**
* The window @p w got hidden but not yet closed.
* This can happen when a window is still being used and is supposed to be shown again
* with @link{windowShown}. On X11 an example is autohiding panels. On Wayland every
* window first goes through the window hidden state and might get shown again, or might
* get closed the normal way.
*
* @see windowShown
* @see windowClosed
* @since 5.8
**/
void windowHidden(KWin::EffectWindow *w);
protected:
QVector< EffectPair > loaded_effects;
//QHash< QString, EffectFactory* > effect_factories;