summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-16 16:56:27 +0200
committerSimon Rettberg2018-07-16 16:56:27 +0200
commit0adb4aa26d7b9ea9c35827750d8ba96daddcee47 (patch)
tree3760bede00de6862738521d0fe2e8eb80193c1fa
parent[client] Fix translation on Qt5 (diff)
downloadpvs2-0adb4aa26d7b9ea9c35827750d8ba96daddcee47.tar.gz
pvs2-0adb4aa26d7b9ea9c35827750d8ba96daddcee47.tar.xz
pvs2-0adb4aa26d7b9ea9c35827750d8ba96daddcee47.zip
[client] Show vnc window on rightmost screen
In Multiscreen setups, we most likely show the VM on the primary (=leftmost) screen.
-rw-r--r--src/client/vnc/vncwindow.cpp29
-rw-r--r--src/client/vnc/vncwindow.h1
2 files changed, 23 insertions, 7 deletions
diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp
index c9c0d93..3ad75e8 100644
--- a/src/client/vnc/vncwindow.cpp
+++ b/src/client/vnc/vncwindow.cpp
@@ -22,7 +22,7 @@
#include <QTimer>
VncWindow::VncWindow(QWidget *parent) :
- QWidget(parent), _vncWorker(NULL), _viewOnly(true), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0)
+ QWidget(parent), _vncWorker(NULL), _viewOnly(true), _multiScreen(false), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0)
{
QTimer *upper = new QTimer(this);
connect(upper, SIGNAL(timeout()), this, SLOT(timer_moveToTop()));
@@ -40,7 +40,7 @@ VncWindow::~VncWindow()
/**
* Terminates the vnc worker thread and stops all related timers.
* The thread will be signalled to stop, but we don't wait for it
- * to actually terminate. All signaled of the thread are blocked, and we NULL
+ * to actually terminate. All signals of the thread are blocked, and we NULL
* our reference to it. It will finish running in a detached state and finally
* delete itself upon completion.
*/
@@ -123,22 +123,34 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool
_remoteThumb.loadFromData(rawThumb);
+ QSize size;
if (fullscreen) {
setWindowFlags(Qt::WindowStaysOnTopHint); // | Qt::X11BypassWindowManagerHint); <- better, but window won't get any keyboard input
+ // Show projection on rightmost screen
QDesktopWidget *desktop = QApplication::desktop();
- QRect size = desktop->screenGeometry(this);
- resize(size.size());
+ int ns = desktop->numScreens();
+ QRect best;
+ for (int i = 0; i < ns; ++i) {
+ QRect r = desktop->screenGeometry(i);
+ if (best.isNull() || r.left() > best.left()) {
+ best = r;
+ }
+ }
+ _multiScreen = ns > 1;
+ size = best.size();
+ setGeometry(best);
showFullScreen();
activateWindow();
raise();
} else {
- resize(800, 600);
+ size = QSize(800, 600);
+ resize(size);
showNormal();
}
this->repaint();
this->show();
- _vncWorker->setTargetSize(this->size());
+ _vncWorker->setTargetSize(size);
_tcpTimeoutTimer = startTimer(10000);
_vncWorker->start(QThread::LowPriority);
@@ -193,6 +205,7 @@ void VncWindow::onProjectionStarted()
}
emit running(true, _clientId);
_redrawTimer = startTimer(3000);
+ _vncWorker->setTargetSize(this->size());
}
/**
@@ -211,7 +224,9 @@ void VncWindow::timer_moveToTop()
{
if (this->isHidden())
return;
- activateWindow();
+ if (!_multiScreen) {
+ activateWindow();
+ }
raise();
}
diff --git a/src/client/vnc/vncwindow.h b/src/client/vnc/vncwindow.h
index 277339c..df37513 100644
--- a/src/client/vnc/vncwindow.h
+++ b/src/client/vnc/vncwindow.h
@@ -50,6 +50,7 @@ protected:
private:
VncThread *_vncWorker;
bool _viewOnly;
+ bool _multiScreen;
int _clientId;
int _redrawTimer;
int _tcpTimeoutTimer;