From c2e9c13b25804ee697bc50c7dfa5d0b810bfc5bf Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 31 Jul 2018 15:06:41 +0200 Subject: [SERVER] Fix locking when locked unicast is current mode Streaming source wasn't locked properly before --- CMakeLists.txt | 2 +- src/client/util/platform/blankscreen.cpp | 5 +++-- src/server/mainwindow/mainwindow.cpp | 14 +++++++++----- src/server/net/client.cpp | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d536232..5e1b550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(EXTRA_CXX_FLAGS "" CACHE STRING "Additional options to pass to C++ compiler" # set compiler optimizations for debug and release SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wunused -Wunreachable-code -pedantic") SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Wextra -Wpedantic -std=c++0x -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") # -Wshadow spams too much :/ SET(CMAKE_CXX_STANDARD 11) diff --git a/src/client/util/platform/blankscreen.cpp b/src/client/util/platform/blankscreen.cpp index bf34614..5f9b04b 100644 --- a/src/client/util/platform/blankscreen.cpp +++ b/src/client/util/platform/blankscreen.cpp @@ -56,8 +56,9 @@ bool BlankScreen::lock(const QString& message) this->raise(); // grabbing of keyboard and mouse - XGrabKeyboard(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy) , false, GrabModeAsync, GrabModeAsync, CurrentTime); - XGrabPointer(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy) , false, 0, GrabModeAsync, GrabModeAsync, None, 0, CurrentTime); +# + XGrabKeyboard(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, GrabModeAsync, GrabModeAsync, CurrentTime); + XGrabPointer(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, 0, GrabModeAsync, GrabModeAsync, None, 0, CurrentTime); QProcess ungrabP; diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 73fcbaf..62e15d2 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -599,16 +599,19 @@ void MainWindow::reset(bool lock) { _mode = Mode::None; + // Stop server (Clients get stopped on ACK) + if (getClientFromId(_streamingSource) != nullptr) { + getClientFromId(_streamingSource)->stopVncServer(); + } + // Unlock all clients - for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { if ((*it)->client() != nullptr) { (*it)->client()->lockScreen(lock); (*it)->client()->removeAttention(); } + } - // Stop server (Clients get stopped on ACK) - if (getClientFromId(_streamingSource) != nullptr) - getClientFromId(_streamingSource)->stopVncServer(); } /* @@ -1219,7 +1222,8 @@ void MainWindow::onVncServerStateChange(Client* client) } } // Dont forget to unlock the vnc server (if necesarry) - client->lockScreen(client->desiredProjectionSource() == NO_SOURCE && _mode == Mode::LockedUnicast); + client->lockScreen((client->desiredProjectionSource() == NO_SOURCE && _mode == Mode::LockedUnicast) + || ui->action_Lock->isChecked()); // If this was the current source remember that there is no source anymore and reset mode if (client == getClientFromId(_streamingSource)) { diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 9b2101f..3920ef7 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -22,7 +22,7 @@ Client::Client(QTcpSocket* socket) : _socket(socket) assert(socket != nullptr); _authed = 0; _projectionSource = 0; - _desiredSource = 0; + _desiredSource = NO_SOURCE; _isActiveVncClient = false; _vncPort = 0; _isTutor = false; @@ -305,6 +305,7 @@ void Client::stopVncClient() msg.setField(_ID, _VNCCLIENT); sendMessage(msg); } + _desiredSource = NO_SOURCE; } /***************************************************************************//** -- cgit v1.2.3-55-g7522