Skip to content

Commit

Permalink
refactor(server): remove setupClient function
Browse files Browse the repository at this point in the history
It's only called once. Simplifies the code.
  • Loading branch information
romangg committed Jan 6, 2024
1 parent 7ff41b0 commit 269b61a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
23 changes: 9 additions & 14 deletions server/wayland/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,16 @@ Client* Display::getClient(wl_client* wlClient)
Server::Client* Display::createClientHandle(wl_client* wlClient)
{
auto priv_cl = Client::create_client(wlClient, this);
setupClient(priv_cl);
return priv_cl->handle;
}
m_clients.push_back(priv_cl);

void Display::setupClient(Client* client)
{
m_clients.push_back(client);

QObject::connect(
client->handle, &Server::Client::disconnected, handle, [this](Server::Client* client) {
remove_all_if(m_clients,
[client](auto&& candidate) { return candidate->handle == client; });
Q_EMIT handle->clientDisconnected(client);
});
Q_EMIT handle->clientConnected(client->handle);
QObject::connect(priv_cl->handle, &Server::Client::disconnected, handle, [this](auto client) {
remove_all_if(m_clients,
[client](auto&& candidate) { return candidate->handle == client; });
Q_EMIT handle->clientDisconnected(client);
});

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

std::vector<Client*> const& Display::clients() const
Expand Down
1 change: 0 additions & 1 deletion server/wayland/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Display
Client* getClient(wl_client* wlClient);

Server::Client* createClientHandle(wl_client* wlClient);
void setupClient(Client* client);

std::vector<Client*> const& clients() const;

Expand Down

0 comments on commit 269b61a

Please sign in to comment.