Skip to content

Commit

Permalink
refactor(server): emit clientConnected only on implicit creation
Browse files Browse the repository at this point in the history
When a client binds the first time to some global emit clientConnected, but
don't emit it when a client is explicitly created by a consumer. Consumers
are expected to initiate respective steps manually then.
  • Loading branch information
romangg committed Jan 6, 2024
1 parent e0370fd commit 639960c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions autotests/server/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,13 @@ void TestServerDisplay::testClientConnection()

auto const& constRef = *connection;
QCOMPARE(constRef.native(), wlClient);
QCOMPARE(connectedSpy.count(), 1);
QCOMPARE(connectedSpy.count(), 0);

QCOMPARE(connectedSpy.first().first().value<Wrapland::Server::Client*>(), connection);
QCOMPARE(display.clients().size(), 1);
QCOMPARE(display.clients()[0], connection);

QCOMPARE(connection, display.getClient(wlClient));
QCOMPARE(connectedSpy.count(), 1);
QCOMPARE(connectedSpy.count(), 0);

// Create a second client.
int sv2[2];
Expand All @@ -180,10 +179,7 @@ void TestServerDisplay::testClientConnection()
auto connection2 = display.getClient(client2->native());
QVERIFY(connection2);
QCOMPARE(connection2, client2);
QCOMPARE(connectedSpy.count(), 2);
QCOMPARE(connectedSpy.first().first().value<Wrapland::Server::Client*>(), connection);
QCOMPARE(connectedSpy.last().first().value<Wrapland::Server::Client*>(), connection2);
QCOMPARE(connectedSpy.last().first().value<Wrapland::Server::Client*>(), client2);
QCOMPARE(connectedSpy.count(), 0);
QCOMPARE(display.clients().size(), 2);
QCOMPARE(display.clients()[0], connection);
QCOMPARE(display.clients()[1], connection2);
Expand Down
1 change: 0 additions & 1 deletion server/wayland/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ Server::Client* Display::createClientHandle(wl_client* wlClient)
Q_EMIT handle->clientDisconnected(client);
});

Q_EMIT handle->clientConnected(priv_cl->handle);
return priv_cl->handle;
}

Expand Down
1 change: 1 addition & 0 deletions server/wayland/nucleus.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Nucleus : public BasicNucleus
// Now the client must be available.
// TODO(romangg): otherwise send protocol error (oom)
auto client = get_client();
Q_EMIT nucleus->display->handle->clientConnected(client->handle);
bind_to_global(client);
}

Expand Down

0 comments on commit 639960c

Please sign in to comment.