From 4c0908ef44176cf0a48590948142efaa6573d210 Mon Sep 17 00:00:00 2001 From: iota97 Date: Sat, 10 Oct 2020 16:26:07 +0200 Subject: [PATCH] Make Qt apply fullscreen change from UI as well --- Qt/mainwindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index c2301004d3..a38e7f1fa3 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -24,13 +24,6 @@ MainWindow::MainWindow(QWidget *parent, bool fullscreen) : nextState(CORE_POWERDOWN), lastUIState(UISTATE_MENU) { - QDesktopWidget *desktop = QApplication::desktop(); - int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt(); - - // Move window to the center of selected screen - QRect rect = desktop->screenGeometry(screenNum); - move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4); - setWindowIcon(QIcon(qApp->applicationDirPath() + "/assets/icon_regular_72.png")); SetGameTitle(""); @@ -64,6 +57,9 @@ void MainWindow::newFrame() updateMenus(); } + if (g_Config.bFullScreen != isFullScreen()) + SetFullScreen(g_Config.bFullScreen); + std::unique_lock lock(msgMutex_); while (!msgQueue_.empty()) { MainWindowMsg msg = msgQueue_.front(); @@ -112,9 +108,6 @@ void MainWindow::updateMenus() void MainWindow::bootDone() { - if (g_Config.bFullScreen != isFullScreen()) - SetFullScreen(g_Config.bFullScreen); - if (nextState == CORE_RUNNING) runAct(); updateMenus(); @@ -389,6 +382,13 @@ void MainWindow::SetFullScreen(bool fullscreen) { if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); + + QDesktopWidget *desktop = QApplication::desktop(); + int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt(); + + // Move window to the center of selected screen + QRect rect = desktop->screenGeometry(screenNum); + move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4); } }