From 7f98d51d4432a2bf1d95b3d87b167a6e275c250f Mon Sep 17 00:00:00 2001 From: jasaaved Date: Wed, 25 Mar 2026 09:52:25 -0700 Subject: [PATCH] Original position restored from Fullscreen When using a separate window, the window position is now saved after exiting fullscreen. Subsequent exits from fullscreen will restore the window to this saved position. Additional coding style issues have been fixed. Changed "primary monitor" to "default monitor" --- .../Config/Graphics/GeneralWidget.cpp | 9 ++++----- Source/Core/DolphinQt/MainWindow.cpp | 19 ++++++++++--------- Source/Core/DolphinQt/MainWindow.h | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp index bda9aa3bd3..df93065b8e 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp @@ -94,7 +94,7 @@ void GeneralWidget::CreateWidgets() video_layout->addWidget(m_custom_aspect_height, 3, 2); m_monitor_combo = new ToolTipComboBox; - m_monitor_combo->addItem(tr("Primary Monitor")); + m_monitor_combo->addItem(tr("Default Monitor")); const QList screens = QGuiApplication::screens(); for (int i = 0; i < screens.size(); i++) m_monitor_combo->addItem(tr("Monitor %1: %2").arg(i + 1).arg(screens[i]->name())); @@ -170,9 +170,8 @@ void GeneralWidget::ConnectWidgets() Config::SetBaseOrCurrent(Config::GFX_ADAPTER, index); emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND))); }); - connect(m_monitor_combo, &QComboBox::currentIndexChanged, this, [](int index) { - Config::SetBaseOrCurrent(Config::MAIN_DISPLAY_MONITOR, index); - }); + connect(m_monitor_combo, &QComboBox::currentIndexChanged, this, + [](int index) { Config::SetBaseOrCurrent(Config::MAIN_DISPLAY_MONITOR, index); }); connect(m_aspect_combo, &QComboBox::currentIndexChanged, this, &GeneralWidget::ToggleCustomAspectRatio); } @@ -328,7 +327,7 @@ void GeneralWidget::AddDescriptions() m_monitor_combo->SetTitle(tr("Display Monitor")); m_monitor_combo->SetDescription( tr("Selects which display to use when rendering.

" - "If unsure, select Primary Monitor.")); + "If unsure, select Default Monitor.")); m_aspect_combo->SetTitle(tr("Aspect Ratio")); m_aspect_combo->SetDescription(tr(TR_ASPECT_RATIO_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index d4e0c4cb3e..6d3fa70955 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1088,7 +1088,7 @@ void MainWindow::FullScreen() if (was_fullscreen) { - ShowRenderWidget(); + ShowRenderWidget(true); } else { @@ -1246,23 +1246,22 @@ void MainWindow::SetFullScreenResolution(bool fullscreen) #endif } -void MainWindow::ShowRenderWidget() +void MainWindow::ShowRenderWidget(bool from_fullscreen) { SetFullScreenResolution(false); Host::GetInstance()->SetRenderFullscreen(false); const int monitor_index = Config::Get(Config::MAIN_DISPLAY_MONITOR); const QList screens = QGuiApplication::screens(); - QScreen* const target_screen = (monitor_index > 0 && monitor_index <= screens.size()) - ? screens[monitor_index - 1] - : QGuiApplication::primaryScreen(); + QScreen* const target_screen = (monitor_index > 0 && monitor_index <= screens.size()) ? + screens[monitor_index - 1] : + QGuiApplication::primaryScreen(); if (Config::Get(Config::MAIN_RENDER_TO_MAIN)) { // Move the main window to the selected monitor if it isn't already there. // Guard with isEmpty() so fullscreen toggles don't overwrite the saved geometry. - if (monitor_index > 0 && screen() != target_screen && - m_pre_game_main_window_geometry.isEmpty()) + if (monitor_index > 0 && screen() != target_screen && m_pre_game_main_window_geometry.isEmpty()) { m_pre_game_main_window_geometry = saveGeometry(); const QRect geo = target_screen->availableGeometry(); @@ -1281,12 +1280,14 @@ void MainWindow::ShowRenderWidget() } else { - // Separate window: restore saved size, then center on the selected monitor if one is set. + // Separate window: restore saved size and position. Only center on the selected monitor + // when first showing the window; skip when returning from fullscreen so the saved position + // is preserved. m_rendering_to_main = false; m_render_widget->showNormal(); m_render_widget->restoreGeometry(m_render_widget_geometry); - if (monitor_index > 0) + if (monitor_index > 0 && !from_fullscreen) { const QRect geo = target_screen->availableGeometry(); m_render_widget->move(geo.x() + (geo.width() - m_render_widget->width()) / 2, diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index f43fb059cf..e1cffee508 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -163,7 +163,7 @@ private: void StartGame(const std::vector& paths, std::unique_ptr boot_session_data = nullptr); void StartGame(std::unique_ptr&& parameters); - void ShowRenderWidget(); + void ShowRenderWidget(bool from_fullscreen = false); void HideRenderWidget(bool reinit = true, bool is_exit = false); void ShowSettingsWindow();