From fe2563ed97451a7c0dd44dd456e3167620c5b10d Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 17 Aug 2020 02:19:58 -0300 Subject: [PATCH] Unite geometry backup --- src/citra_qt/bootmanager.cpp | 37 +++++++++--------------------------- src/citra_qt/bootmanager.h | 7 ------- src/citra_qt/main.cpp | 5 +++-- 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 9c9e99232..7b71699cc 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -13,6 +13,7 @@ #include #include "citra_qt/bootmanager.h" #include "citra_qt/main.h" +#include "citra_qt/uisettings.h" #include "common/microprofile.h" #include "common/scm_rev.h" #include "core/3ds.h" @@ -235,31 +236,6 @@ void GRenderWindow::OnFramebufferSizeChanged() { UpdateCurrentFramebufferLayout(width, height); } -void GRenderWindow::BackupGeometry() { - geometry = QWidget::saveGeometry(); -} - -void GRenderWindow::RestoreGeometry() { - // We don't want to back up the geometry here (obviously) - QWidget::restoreGeometry(geometry); -} - -void GRenderWindow::restoreGeometry(const QByteArray& geometry) { - // Make sure users of this class don't need to deal with backing up the geometry themselves - QWidget::restoreGeometry(geometry); - BackupGeometry(); -} - -QByteArray GRenderWindow::saveGeometry() { - // If we are a top-level widget, store the current geometry - // otherwise, store the last backup - if (parent() == nullptr) { - return QWidget::saveGeometry(); - } - - return geometry; -} - qreal GRenderWindow::windowPixelRatio() const { return devicePixelRatioF(); } @@ -381,20 +357,25 @@ void GRenderWindow::InitRenderTarget() { first_frame = false; + const auto min_size = Layout::GetMinimumSizeFromLayout(Settings::values.layout_option, + Settings::values.upright_screen); + + restoreGeometry(UISettings::values.renderwindow_geometry); + GMainWindow* parent = GetMainWindow(); QWindow* parent_win_handle = parent ? parent->windowHandle() : nullptr; child_window = new OpenGLWindow(parent_win_handle, this, QOpenGLContext::globalShareContext()); child_window->create(); child_widget = createWindowContainer(child_window, this); - child_widget->resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); + child_widget->resize(min_size.first, min_size.second); layout()->addWidget(child_widget); core_context = CreateSharedContext(); - resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); + resize(min_size.first, min_size.second); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); OnFramebufferSizeChanged(); - BackupGeometry(); + UISettings::values.renderwindow_geometry = saveGeometry(); } void GRenderWindow::ReleaseRenderTarget() { diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index c0f1134b8..fcb5cb3ef 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -155,11 +155,6 @@ public: void PollEvents() override; std::unique_ptr CreateSharedContext() const override; - void BackupGeometry(); - void RestoreGeometry(); - void restoreGeometry(const QByteArray& geometry); // overridden - QByteArray saveGeometry(); // overridden - qreal windowPixelRatio() const; void closeEvent(QCloseEvent* event) override; @@ -212,8 +207,6 @@ private: std::unique_ptr core_context; - QByteArray geometry; - /// Native window handle that backs this presentation widget QWindow* child_window = nullptr; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5a26d6c53..a3e9bbd34 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1654,7 +1654,7 @@ void GMainWindow::HideFullscreen() { void GMainWindow::ToggleWindowMode() { if (ui->action_Single_Window_Mode->isChecked()) { // Render in the main window... - render_window->BackupGeometry(); + UISettings::values.renderwindow_geometry = render_window->saveGeometry(); ui->horizontalLayout->addWidget(render_window); render_window->setFocusPolicy(Qt::StrongFocus); if (emulation_running) { @@ -1670,7 +1670,7 @@ void GMainWindow::ToggleWindowMode() { render_window->setFocusPolicy(Qt::NoFocus); if (emulation_running) { render_window->setVisible(true); - render_window->RestoreGeometry(); + render_window->restoreGeometry(UISettings::values.renderwindow_geometry); game_list->show(); } } @@ -2175,6 +2175,7 @@ void GMainWindow::resizeEvent(QResizeEvent* event) { } else { UncheckWindowSize(); } + QWidget::resizeEvent(event); } void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {