From abe7874c73ec70a9855f8f513f6143d3a4f2e59c Mon Sep 17 00:00:00 2001 From: Georges Berenger Date: Wed, 29 Nov 2023 21:38:12 -0800 Subject: [PATCH] Update max window size when the window is moved Summary: In multi-monitor situations, we need to update the max size of the window after it's been moved, in case it's been going from one display to another, as these may have different dimensions. Otherwise, the max size of the window might no longer match the particular display's dimensions. Reviewed By: kiminoue7 Differential Revision: D51692135 fbshipit-source-id: 863d9fc081676744464c67405a4311b6e3d9b252 --- tools/vrsplayer/PlayerUI.cpp | 4 ++-- tools/vrsplayer/PlayerUI.h | 2 +- tools/vrsplayer/PlayerWindow.cpp | 5 +++++ tools/vrsplayer/PlayerWindow.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/vrsplayer/PlayerUI.cpp b/tools/vrsplayer/PlayerUI.cpp index 81481b5a..d9ec9a15 100644 --- a/tools/vrsplayer/PlayerUI.cpp +++ b/tools/vrsplayer/PlayerUI.cpp @@ -309,7 +309,7 @@ void PlayerUI::resizeToDefault() { #endif } -void PlayerUI::resizeIfNecessary() { +void PlayerUI::resizeIfNecessary(bool maxSizeOnly) { #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QRect screenRect = QApplication::desktop()->screenGeometry(this); #else @@ -319,7 +319,7 @@ void PlayerUI::resizeIfNecessary() { QRect windowInScreen(mapToGlobal(windowRect.topLeft()), mapToGlobal(windowRect.bottomRight())); if (screenRect.contains(windowInScreen)) { window()->setMaximumSize(screenRect.size()); - } else { + } else if (!maxSizeOnly) { resizeToDefault(); } } diff --git a/tools/vrsplayer/PlayerUI.h b/tools/vrsplayer/PlayerUI.h index cd0c481c..51bd510c 100644 --- a/tools/vrsplayer/PlayerUI.h +++ b/tools/vrsplayer/PlayerUI.h @@ -53,7 +53,7 @@ class PlayerUI : public QWidget { void openPath(const QString& url); void resizeToDefault(); - void resizeIfNecessary(); + void resizeIfNecessary(bool maxSizeOnly = false); FileReader& getFileReader() { return fileReader_; } diff --git a/tools/vrsplayer/PlayerWindow.cpp b/tools/vrsplayer/PlayerWindow.cpp index 59d9cb83..ab794da7 100644 --- a/tools/vrsplayer/PlayerWindow.cpp +++ b/tools/vrsplayer/PlayerWindow.cpp @@ -114,6 +114,11 @@ void PlayerWindow::createMenus() { orientationMenu_->addAction(resetAction); } +void PlayerWindow::moveEvent(QMoveEvent* event) { + player_.resizeIfNecessary(true); + QMainWindow::moveEvent(event); +} + void PlayerWindow::updateLayoutMenu( int frameCount, int visibleCount, diff --git a/tools/vrsplayer/PlayerWindow.h b/tools/vrsplayer/PlayerWindow.h index e0b64858..c00e0e6a 100644 --- a/tools/vrsplayer/PlayerWindow.h +++ b/tools/vrsplayer/PlayerWindow.h @@ -43,6 +43,7 @@ class PlayerWindow : public QMainWindow { PlayerUI& getPlayerUI() { return player_; } + void moveEvent(QMoveEvent* event) override; signals: