[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: Merge signal connections for AbstractClient in Workspace
From:       Martin_Gräßlin <mgraesslin () kde ! org>
Date:       2016-07-13 8:49:33
Message-ID: E1bNFrJ-0000MM-Ac () code ! kde ! org
[Download RAW message or body]

Git commit 445335ba5f3305ed71de5753061124fc7823b406 by Martin Gräßlin.
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/integration/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 \
                <http://www.gnu.org/licenses/>.
 *********************************************************************/
 #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> surface(Test::createSurface());
+    QScopedPointer<ShellSurface> \
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<AbstractClient*>(), \
c); +    QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1);
+    QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), \
c); +    QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1);
+    QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), \
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 = 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 16fcf29..dd6dee8 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<void \
                (Compositor::*)()>(&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 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);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic