From 28a0562d0303d3bf27fa292bc170661f4d0cb8a4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 2 Aug 2018 14:42:29 +0200 Subject: [server] Don't restart VNC viewer if target stays the same --- src/server/mainwindow/mainwindow.cpp | 18 ++++++++++-------- src/server/net/client.cpp | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index a7648b9..9a28a55 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -1169,15 +1169,17 @@ void MainWindow::onVncServerStateChange(Client* client) if (client->isActiveVncServer()) { // apply the desired projection sources - for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - if ( (*it)->client() != nullptr) { // Ignore offline clients - if ( (*it)->client()->desiredProjectionSource() == client->id() ) - (*it)->client()->startVncClient(client); - else - (*it)->client()->stopVncClient(); - - (*it)->client()->lockScreen((*it)->client()->desiredProjectionSource() == NO_SOURCE && _mode == Mode::LockedUnicast); + for (ConnectionFrame *frame : _clientFrames) { + if (frame->client() == nullptr) // Ignore offline clients + continue; + if (frame->client()->desiredProjectionSource() == client->id()) { + frame->client()->startVncClient(client); + client->lockScreen(false); + } + if (frame->client()->desiredProjectionSource() == NO_SOURCE && _mode == Mode::LockedUnicast) { + frame->client()->lockScreen(true); } + } // Dont forget to unlock the vnc server client->lockScreen(false); } else { diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 3920ef7..ad101a1 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -284,6 +284,8 @@ void Client::stopVncServer() /******************************************************************************/ void Client::startVncClient(const Client * const to) { + if (_projectionSource == to->_id) + return; // Already watching given target, do nothing NetworkMessage msg; msg.setField(_ID, _VNCCLIENT); msg.setField("HOST", to->_socket->peerAddress().toString()); -- cgit v1.2.3-55-g7522