diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp
index ab1846d7c0..1d9cff47e5 100644
--- a/autotests/integration/shell_client_test.cpp
+++ b/autotests/integration/shell_client_test.cpp
@@ -19,6 +19,7 @@ along with this program. If not, see .
*********************************************************************/
#include "kwin_wayland_test.h"
#include "cursor.h"
+#include "effects.h"
#include "platform.h"
#include "shell_client.h"
#include "screens.h"
@@ -46,6 +47,7 @@ private Q_SLOTS:
void cleanup();
void testMapUnmapMap();
+ void testDesktopPresenceChanged();
};
void TestShellClient::initTestCase()
@@ -131,5 +133,41 @@ void TestShellClient::testMapUnmapMap()
QCOMPARE(windowClosedSpy.count(), 1);
}
+void TestShellClient::testDesktopPresenceChanged()
+{
+ // this test verifies that the desktop presence changed signals are properly emitted
+ QScopedPointer surface(Test::createSurface());
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
+ auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
+ QVERIFY(c);
+ QCOMPARE(c->desktop(), 1);
+ effects->setNumberOfDesktops(4);
+ QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged);
+ QVERIFY(desktopPresenceChangedClientSpy.isValid());
+ QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged);
+ QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid());
+ QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged);
+ QVERIFY(desktopPresenceChangedEffectsSpy.isValid());
+
+ // let's change the desktop
+ workspace()->sendClientToDesktop(c, 2, false);
+ QCOMPARE(c->desktop(), 2);
+ QCOMPARE(desktopPresenceChangedClientSpy.count(), 1);
+ QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1);
+ // effects is delayed by one cycle
+ QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 0);
+ QVERIFY(desktopPresenceChangedEffectsSpy.wait());
+ QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1);
+
+ // verify the arguments
+ QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value(), c);
+ QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1);
+ QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value(), c);
+ QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1);
+ QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value(), c->effectWindow());
+ QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1);
+ QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2);
+}
+
WAYLANDTEST_MAIN(TestShellClient)
#include "shell_client_test.moc"
diff --git a/wayland_server.cpp b/wayland_server.cpp
index 117f92fc12..2b3152cad0 100644
--- a/wayland_server.cpp
+++ b/wayland_server.cpp
@@ -162,9 +162,6 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags)
ScreenLocker::KSldApp::self()->lockScreenShown();
}
auto client = new ShellClient(surface);
- if (auto c = Compositor::self()) {
- connect(client, &Toplevel::needsRepaint, c, &Compositor::scheduleRepaint);
- }
if (client->isInternal()) {
m_internalClients << client;
} else {
diff --git a/workspace.cpp b/workspace.cpp
index 16fcf29e4b..dd6dee8038 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -368,6 +368,7 @@ void Workspace::init()
if (auto w = waylandServer()) {
connect(w, &WaylandServer::shellClientAdded, this,
[this] (ShellClient *c) {
+ setupClientConnections(c);
c->updateDecoration(false);
updateClientLayer(c);
if (!c->isInternal()) {
@@ -483,18 +484,23 @@ Workspace::~Workspace()
_self = 0;
}
+void Workspace::setupClientConnections(AbstractClient *c)
+{
+ connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::scheduleRepaint);
+ connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
+}
+
Client* Workspace::createClient(xcb_window_t w, bool is_mapped)
{
StackingUpdatesBlocker blocker(this);
Client* c = new Client();
- connect(c, SIGNAL(needsRepaint()), m_compositor, SLOT(scheduleRepaint()));
+ setupClientConnections(c);
connect(c, &Client::activeChanged, m_compositor, static_cast(&Compositor::checkUnredirect));
connect(c, SIGNAL(fullScreenChanged()), m_compositor, SLOT(checkUnredirect()));
connect(c, SIGNAL(geometryChanged()), m_compositor, SLOT(checkUnredirect()));
connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), m_compositor, SLOT(checkUnredirect()));
connect(c, SIGNAL(blockingCompositingChanged(KWin::Client*)), m_compositor, SLOT(updateCompositeBlocking(KWin::Client*)));
connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking()));
- connect(c, &Client::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
if (!c->manage(w, is_mapped)) {
Client::deleteClient(c);
return NULL;
diff --git a/workspace.h b/workspace.h
index 0c07bed52d..5589f7d891 100644
--- a/workspace.h
+++ b/workspace.h
@@ -512,6 +512,7 @@ private:
/// This is the right way to create a new client
Client* createClient(xcb_window_t w, bool is_mapped);
+ void setupClientConnections(AbstractClient *client);
void addClient(Client* c);
Unmanaged* createUnmanaged(xcb_window_t w);
void addUnmanaged(Unmanaged* c);