From 4a9499bbe5e6f3e95066ab2e6b98e1a58500010a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 18 Jul 2018 15:20:17 +0200 Subject: [server] Don't do unnecessary lock resets on mode change --- src/server/mainwindow/mainwindow.cpp | 33 +++++++++++++-------------------- src/server/mainwindow/mainwindow.h | 2 +- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 9f71f93..568896c 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -388,8 +388,6 @@ void MainWindow::tellClientCurrentSituation(Client* client) client->startVncClient(getClientFromId(_streamingSource)); } } - - } /***************************************************************************//** @@ -610,14 +608,14 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) /***************************************************************************//** * @brief reset */ -void MainWindow::reset() +void MainWindow::reset(bool lock) { _mode = Mode::None; // Unlock all clients for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) if ((*it)->client() != NULL) { - (*it)->client()->lockScreen(false); + (*it)->client()->lockScreen(lock); (*it)->client()->removeAttention(); } @@ -676,11 +674,10 @@ void MainWindow::onSessionNameClick() if (_countSessionNameUpdate > 1) { int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to change SessionName again?\n" "All Clients will be deleted afterwards."), 0, 1, 2); - if (ret == 1) { - _sessionNameWindow->show(serverApp->sessionName()); - } - } else - _sessionNameWindow->show((serverApp->sessionName())); + if (ret != 1) + return; + } + _sessionNameWindow->show((serverApp->sessionName())); } /***************************************************************************//** @@ -988,8 +985,10 @@ void MainWindow::onButtonStudentToTutorExclusive() else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else { + Client *selectedClient = getSelectedFrame()->client(); + Client *tutorClient = getTutorFrame()->client(); // If this is not the first run in this mode and the current source is selected, stop the streaming. - if (_mode == Mode::Unicast && getSelectedFrame()->client()->id() == _streamingSource) { + if ((_mode == Mode::Unicast || _mode == Mode::LockedUnicast) && selectedClient->id() == _streamingSource) { // Stop reset everything _mode = Mode::None; reset(); @@ -999,11 +998,11 @@ void MainWindow::onButtonStudentToTutorExclusive() // Unset all clients desired sources. Except the tutors desired source, this has to be the selecteds frame for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) if ((*it)->client() != NULL) - (*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id() : NO_SOURCE); + (*it)->client()->setDesiredProjectionSource(tutorClient->id() == (*it)->client()->id() ? selectedClient->id() : NO_SOURCE); disableButtons(); _mode = Mode::LockedUnicast; - startVncServerIfNecessary(getSelectedFrame()->client()->id()); + startVncServerIfNecessary(selectedClient->id()); } } @@ -1027,14 +1026,8 @@ void MainWindow::onButtonStopProjection() */ void MainWindow::onButtonLock(bool checked) { - // Stop all projections - reset(); - - for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->client() == NULL) - continue; - (*it)->client()->lockScreen(checked); - } + // Stop all projections and lock if requested + reset(checked); } void MainWindow::onButtonLockSingle() diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 4e880e6..cf7b068 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -85,7 +85,7 @@ private: void savePosition(ConnectionFrame *cf); void startVncServerIfNecessary(int from); void tellClientCurrentSituation(Client* client); - void reset(); + void reset(bool lock = false); Client* getClientFromId(int id); ConnectionFrame* getTutorFrame(); ConnectionFrame* getSelectedFrame(); -- cgit v1.2.3-55-g7522