mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 19:21:04 +00:00
Unite geometry backup
This commit is contained in:
parent
a54ea07d6f
commit
fe2563ed97
@ -13,6 +13,7 @@
|
||||
#include <fmt/format.h>
|
||||
#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() {
|
||||
|
@ -155,11 +155,6 @@ public:
|
||||
void PollEvents() override;
|
||||
std::unique_ptr<Frontend::GraphicsContext> 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<GraphicsContext> core_context;
|
||||
|
||||
QByteArray geometry;
|
||||
|
||||
/// Native window handle that backs this presentation widget
|
||||
QWindow* child_window = nullptr;
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user