From ac0ec0a458551ed86685e832521d82950d154627 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Thu, 30 Jul 2015 17:09:08 -0700 Subject: [PATCH] Ensure the app moves back to a non-rift screen if the saved geometry is bad --- interface/src/Application.cpp | 23 ++++++++++++++++--- interface/src/Application.h | 2 +- .../plugins/src/plugins/PluginContainer.h | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 582f782486..c9cbfe6066 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4693,16 +4693,33 @@ void Application::setFullscreen(const QScreen* target) { _window->showFullScreen(); } -void Application::unsetFullscreen() { +void Application::unsetFullscreen(const QScreen* avoid) { _window->showNormal(); + + QRect targetGeometry = _savedGeometry; + if (avoid != nullptr) { + QRect avoidGeometry = avoid->geometry(); + if (avoidGeometry.contains(targetGeometry.topLeft())) { + QScreen* newTarget = primaryScreen(); + if (newTarget == avoid) { + foreach(auto screen, screens()) { + if (screen != avoid) { + newTarget = screen; + break; + } + } + } + targetGeometry = newTarget->availableGeometry(); + } + } #ifdef Q_OS_MAC QTimer* timer = new QTimer(); timer->singleShot(2000, [=] { - _window->setGeometry(_savedGeometry); + _window->setGeometry(targetGeometry); timer->deleteLater(); }); #else - _window->setGeometry(_savedGeometry); + _window->setGeometry(targetGeometry); #endif } diff --git a/interface/src/Application.h b/interface/src/Application.h index d23218c568..ff68d9613c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -287,7 +287,7 @@ public: virtual bool isOptionChecked(const QString& name); virtual void setIsOptionChecked(const QString& path, bool checked); virtual void setFullscreen(const QScreen* target) override; - virtual void unsetFullscreen() override; + virtual void unsetFullscreen(const QScreen* avoid) override; virtual void showDisplayPluginsTools() override; virtual QGLWidget* getPrimarySurface() override; diff --git a/libraries/plugins/src/plugins/PluginContainer.h b/libraries/plugins/src/plugins/PluginContainer.h index aaa27978f9..93f1659e1a 100644 --- a/libraries/plugins/src/plugins/PluginContainer.h +++ b/libraries/plugins/src/plugins/PluginContainer.h @@ -32,7 +32,7 @@ public: virtual bool isOptionChecked(const QString& name) = 0; virtual void setIsOptionChecked(const QString& path, bool checked) = 0; virtual void setFullscreen(const QScreen* targetScreen) = 0; - virtual void unsetFullscreen() = 0; + virtual void unsetFullscreen(const QScreen* avoidScreen = nullptr) = 0; virtual void showDisplayPluginsTools() = 0; virtual QGLWidget* getPrimarySurface() = 0; };