mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 19:23:28 +02:00
Ensure the app moves back to a non-rift screen if the saved geometry is bad
This commit is contained in:
parent
352ae24fab
commit
ac0ec0a458
3 changed files with 22 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue