Skip to content

Commit

Permalink
Update max window size when the window is moved
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Nov 30, 2023
1 parent 16744f5 commit abe7874
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/vrsplayer/PlayerUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/vrsplayer/PlayerUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand Down
5 changes: 5 additions & 0 deletions tools/vrsplayer/PlayerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tools/vrsplayer/PlayerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class PlayerWindow : public QMainWindow {
PlayerUI& getPlayerUI() {
return player_;
}
void moveEvent(QMoveEvent* event) override;

signals:

Expand Down

0 comments on commit abe7874

Please sign in to comment.