From kde-commits Wed Jul 13 08:49:33 2016 From: =?utf-8?q?Martin_Gr=C3=A4=C3=9Flin?= Date: Wed, 13 Jul 2016 08:49:33 +0000 To: kde-commits Subject: [kwin] /: Merge signal connections for AbstractClient in Workspace Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=146839978930292 Git commit 445335ba5f3305ed71de5753061124fc7823b406 by Martin Gr=C3=A4=C3= =9Flin. Committed on 13/07/2016 at 08:44. Pushed by graesslin into branch 'master'. Merge signal connections for AbstractClient in Workspace Summary: Have one dedicated method which performs the connection for both Client and ShellClient. This fixes the desktopPresenceChanged signal not being passed to the effects. Note that not all signals are merged. Most signals setup for Client don't make sense for ShellClient as ShellClient cannot block composite or unredirect. Test Plan: Test case added for ShellClient to ensure that the signal is correctly invoked on the ShellClient, Workspace and EffectsHandler. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2059 M +38 -0 autotests/integration/shell_client_test.cpp M +0 -3 wayland_server.cpp M +8 -2 workspace.cpp M +1 -0 workspace.h http://commits.kde.org/kwin/445335ba5f3305ed71de5753061124fc7823b406 diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integr= ation/shell_client_test.cpp index ab1846d..1d9cff4 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 pr= operly emitted + QScopedPointer surface(Test::createSurface()); + QScopedPointer shellSurface(Test::createShellSurface(sur= face.data())); + auto c =3D Test::renderAndWaitForShown(surface.data(), QSize(100, 50),= Qt::blue); + QVERIFY(c); + QCOMPARE(c->desktop(), 1); + effects->setNumberOfDesktops(4); + QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPre= senceChanged); + 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 117f92f..2b3152c 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 =3D new ShellClient(surface); - if (auto c =3D Compositor::self()) { - connect(client, &Toplevel::needsRepaint, c, &Compositor::s= cheduleRepaint); - } if (client->isInternal()) { m_internalClients << client; } else { diff --git a/workspace.cpp b/workspace.cpp index 16fcf29..dd6dee8 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -368,6 +368,7 @@ void Workspace::init() if (auto w =3D 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 =3D 0; } = +void Workspace::setupClientConnections(AbstractClient *c) +{ + connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::schedul= eRepaint); + connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::= desktopPresenceChanged); +} + Client* Workspace::createClient(xcb_window_t w, bool is_mapped) { StackingUpdatesBlocker blocker(this); Client* c =3D 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(checkUnredi= rect())); connect(c, SIGNAL(geometryChanged()), m_compositor, SLOT(checkUnredire= ct())); connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), m_comp= ositor, SLOT(checkUnredirect())); connect(c, SIGNAL(blockingCompositingChanged(KWin::Client*)), m_compos= itor, SLOT(updateCompositeBlocking(KWin::Client*))); connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), Scree= nEdges::self(), SIGNAL(checkBlocking())); - connect(c, &Client::desktopPresenceChanged, this, &Workspace::desktopP= resenceChanged); if (!c->manage(w, is_mapped)) { Client::deleteClient(c); return NULL; diff --git a/workspace.h b/workspace.h index 0c07bed..5589f7d 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);