From d058b5554ea87a142c1beac15f5fb40c71a8838b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Dec 2014 16:58:36 -0800 Subject: [PATCH 1/3] make sure the running scripts widget doesn't start on the HMD screen --- interface/src/Application.cpp | 3 --- interface/src/ui/HMDToolsDialog.cpp | 1 - interface/src/ui/HMDToolsDialog.h | 2 ++ interface/src/ui/RunningScriptsWidget.cpp | 28 +++++++++++++++++++---- interface/src/ui/RunningScriptsWidget.h | 2 -- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d773208ac0..dc4b66ad93 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -415,9 +415,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } - connect(_window, &MainWindow::windowGeometryChanged, - _runningScriptsWidget, &RunningScriptsWidget::setBoundary); - _trayIcon->show(); // set the local loopback interface for local sounds from audio scripts diff --git a/interface/src/ui/HMDToolsDialog.cpp b/interface/src/ui/HMDToolsDialog.cpp index 88924f68d1..580490f83b 100644 --- a/interface/src/ui/HMDToolsDialog.cpp +++ b/interface/src/ui/HMDToolsDialog.cpp @@ -79,7 +79,6 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) : // keep track of changes to the number of screens connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged); - } HMDToolsDialog::~HMDToolsDialog() { diff --git a/interface/src/ui/HMDToolsDialog.h b/interface/src/ui/HMDToolsDialog.h index e3e5573533..d539b58d04 100644 --- a/interface/src/ui/HMDToolsDialog.h +++ b/interface/src/ui/HMDToolsDialog.h @@ -22,6 +22,8 @@ public: ~HMDToolsDialog(); QString getDebugDetails() const; + QScreen* getHMDScreen() const { return _hmdScreen; } + bool hasHMDScreen() const { return _hmdScreenNumber >= -1; } signals: void closed(); diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp index 29c004bdb7..4fd19d4588 100644 --- a/interface/src/ui/RunningScriptsWidget.cpp +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include "Application.h" #include "Menu.h" @@ -82,10 +84,6 @@ void RunningScriptsWidget::loadSelectedScript() { } } -void RunningScriptsWidget::setBoundary(const QRect& rect) { - _boundary = rect; -} - void RunningScriptsWidget::setRunningScripts(const QStringList& list) { setUpdatesEnabled(false); QLayoutItem* widget; @@ -153,7 +151,27 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) { ui->filterLineEdit->setFocus(); } - const QRect parentGeometry = parentWidget()->geometry(); + QRect parentGeometry = parentWidget()->geometry(); + + // If our parent window is on the HMD, then don't use it's geometry, instead use + // the "main screen" geometry. + HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); + if (hmdTools && hmdTools->hasHMDScreen()) { + QScreen* hmdScreen = hmdTools->getHMDScreen(); + QWindow* appWindow = parentWidget()->windowHandle(); + QScreen* appScreen = appWindow->screen(); + + // if our app's screen is the hmd screen, we don't want to place the + // running scripts widget on it. So we need to pick a better screen. + // we will use the screen for the HMDTools since it's a guarenteed + // better screen. + if (appScreen == hmdScreen) { + QScreen* betterScreen = hmdTools->windowHandle()->screen(); + parentGeometry = betterScreen->geometry(); + } + + } + int titleBarHeight = UIUtil::getWindowTitleBarHeight(this); int menuBarHeight = Menu::getInstance()->geometry().height(); int topMargin = titleBarHeight + menuBarHeight; diff --git a/interface/src/ui/RunningScriptsWidget.h b/interface/src/ui/RunningScriptsWidget.h index 7493a1a5ce..8eace0c7b1 100644 --- a/interface/src/ui/RunningScriptsWidget.h +++ b/interface/src/ui/RunningScriptsWidget.h @@ -44,7 +44,6 @@ protected: public slots: void scriptStopped(const QString& scriptName); - void setBoundary(const QRect& rect); private slots: void allScriptsStopped(); @@ -61,7 +60,6 @@ private: ScriptsTableWidget* _recentlyLoadedScriptsTable; QStringList _recentlyLoadedScripts; QString _lastStoppedScript; - QRect _boundary; }; #endif // hifi_RunningScriptsWidget_h From 06d348c39936f51acb6398042e5305c5c589e28d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Dec 2014 17:13:34 -0800 Subject: [PATCH 2/3] get have addressbar avoid the hmd screen --- interface/src/ui/FramelessDialog.cpp | 39 +++++++++++++++++++++---- interface/src/ui/RunningScriptsWidget.h | 1 - 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index ab997a0a75..8a170ab78d 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -9,8 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include +#include + #include "Application.h" #include "FramelessDialog.h" +#include "Menu.h" const int RESIZE_HANDLE_WIDTH = 7; @@ -90,24 +94,47 @@ void FramelessDialog::showEvent(QShowEvent* event) { } void FramelessDialog::resizeAndPosition(bool resizeParent) { + QSize parentSize = parentWidget()->size(); + QRect parentGeometry = parentWidget()->geometry(); + + // If our parent window is on the HMD, then don't use it's geometry, instead use + // the "main screen" geometry. + HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); + if (hmdTools && hmdTools->hasHMDScreen()) { + QScreen* hmdScreen = hmdTools->getHMDScreen(); + QWindow* appWindow = parentWidget()->windowHandle(); + QScreen* appScreen = appWindow->screen(); + + // if our app's screen is the hmd screen, we don't want to place the + // running scripts widget on it. So we need to pick a better screen. + // we will use the screen for the HMDTools since it's a guarenteed + // better screen. + if (appScreen == hmdScreen) { + QScreen* betterScreen = hmdTools->windowHandle()->screen(); + parentGeometry = betterScreen->geometry(); + parentSize = betterScreen->size(); + } + + } + // keep full app height or width depending on position if (_position == POSITION_LEFT || _position == POSITION_RIGHT) { - setFixedHeight(parentWidget()->size().height()); + setFixedHeight(parentSize.height()); } else { - setFixedWidth(parentWidget()->size().width()); + setFixedWidth(parentSize.width()); } // resize parrent if width is smaller than this dialog - if (resizeParent && parentWidget()->size().width() < size().width()) { - parentWidget()->resize(size().width(), parentWidget()->size().height()); + if (resizeParent && parentSize.width() < size().width()) { + parentWidget()->resize(size().width(), parentSize.height()); } if (_position == POSITION_LEFT || _position == POSITION_TOP) { // move to upper left corner - move(parentWidget()->geometry().topLeft()); + move(parentGeometry.topLeft()); } else if (_position == POSITION_RIGHT) { // move to upper right corner - QPoint pos = parentWidget()->geometry().topRight(); + QPoint pos = parentGeometry.topRight(); pos.setX(pos.x() - size().width()); move(pos); } diff --git a/interface/src/ui/RunningScriptsWidget.h b/interface/src/ui/RunningScriptsWidget.h index 8eace0c7b1..69833a890b 100644 --- a/interface/src/ui/RunningScriptsWidget.h +++ b/interface/src/ui/RunningScriptsWidget.h @@ -18,7 +18,6 @@ #include #include "ScriptsModel.h" -#include "FramelessDialog.h" #include "ScriptsTableWidget.h" namespace Ui { From ec54b609df13d20a01fe0ecbb18e6550ba2ba5e1 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Dec 2014 17:23:39 -0800 Subject: [PATCH 3/3] dry up code and make chat window avoid the hmd screen --- interface/src/Application.cpp | 24 +++++++++++++++++++++++ interface/src/Application.h | 2 ++ interface/src/ui/ChatWindow.cpp | 2 +- interface/src/ui/FramelessDialog.cpp | 24 ++--------------------- interface/src/ui/RunningScriptsWidget.cpp | 22 +-------------------- 5 files changed, 30 insertions(+), 44 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index dc4b66ad93..cb3acc88f1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -2714,6 +2715,29 @@ bool Application::isHMDMode() const { } } +QRect Application::getDesirableApplicationGeometry() { + QRect applicationGeometry = getWindow()->geometry(); + + // If our parent window is on the HMD, then don't use it's geometry, instead use + // the "main screen" geometry. + HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); + if (hmdTools && hmdTools->hasHMDScreen()) { + QScreen* hmdScreen = hmdTools->getHMDScreen(); + QWindow* appWindow = getWindow()->windowHandle(); + QScreen* appScreen = appWindow->screen(); + + // if our app's screen is the hmd screen, we don't want to place the + // running scripts widget on it. So we need to pick a better screen. + // we will use the screen for the HMDTools since it's a guarenteed + // better screen. + if (appScreen == hmdScreen) { + QScreen* betterScreen = hmdTools->windowHandle()->screen(); + applicationGeometry = betterScreen->geometry(); + } + } + return applicationGeometry; +} + ///////////////////////////////////////////////////////////////////////////////////// // loadViewFrustum() // diff --git a/interface/src/Application.h b/interface/src/Application.h index 0f0bd91210..217d547c89 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -327,6 +327,8 @@ public: // rendering of several elements depend on that // TODO: carry that information on the Camera as a setting bool isHMDMode() const; + + QRect getDesirableApplicationGeometry(); signals: diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 7869926ebe..747b4ae68d 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -124,7 +124,7 @@ void ChatWindow::showEvent(QShowEvent* event) { if (!event->spontaneous()) { _ui->messagePlainTextEdit->setFocus(); } - const QRect parentGeometry = parentWidget()->geometry(); + QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry(); int titleBarHeight = UIUtil::getWindowTitleBarHeight(this); int menuBarHeight = Menu::getInstance()->geometry().height(); int topMargin = titleBarHeight + menuBarHeight; diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index 8a170ab78d..280354d974 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -94,29 +94,9 @@ void FramelessDialog::showEvent(QShowEvent* event) { } void FramelessDialog::resizeAndPosition(bool resizeParent) { - QSize parentSize = parentWidget()->size(); - QRect parentGeometry = parentWidget()->geometry(); + QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry(); + QSize parentSize = parentGeometry.size(); - // If our parent window is on the HMD, then don't use it's geometry, instead use - // the "main screen" geometry. - HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); - if (hmdTools && hmdTools->hasHMDScreen()) { - QScreen* hmdScreen = hmdTools->getHMDScreen(); - QWindow* appWindow = parentWidget()->windowHandle(); - QScreen* appScreen = appWindow->screen(); - - // if our app's screen is the hmd screen, we don't want to place the - // running scripts widget on it. So we need to pick a better screen. - // we will use the screen for the HMDTools since it's a guarenteed - // better screen. - if (appScreen == hmdScreen) { - QScreen* betterScreen = hmdTools->windowHandle()->screen(); - parentGeometry = betterScreen->geometry(); - parentSize = betterScreen->size(); - } - - } - // keep full app height or width depending on position if (_position == POSITION_LEFT || _position == POSITION_RIGHT) { setFixedHeight(parentSize.height()); diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp index 4fd19d4588..cfd7428482 100644 --- a/interface/src/ui/RunningScriptsWidget.cpp +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -151,27 +151,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) { ui->filterLineEdit->setFocus(); } - QRect parentGeometry = parentWidget()->geometry(); - - // If our parent window is on the HMD, then don't use it's geometry, instead use - // the "main screen" geometry. - HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); - if (hmdTools && hmdTools->hasHMDScreen()) { - QScreen* hmdScreen = hmdTools->getHMDScreen(); - QWindow* appWindow = parentWidget()->windowHandle(); - QScreen* appScreen = appWindow->screen(); - - // if our app's screen is the hmd screen, we don't want to place the - // running scripts widget on it. So we need to pick a better screen. - // we will use the screen for the HMDTools since it's a guarenteed - // better screen. - if (appScreen == hmdScreen) { - QScreen* betterScreen = hmdTools->windowHandle()->screen(); - parentGeometry = betterScreen->geometry(); - } - - } - + QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry(); int titleBarHeight = UIUtil::getWindowTitleBarHeight(this); int menuBarHeight = Menu::getInstance()->geometry().height(); int topMargin = titleBarHeight + menuBarHeight;