diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 22b6bcdd7..72d1440a9 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -389,6 +389,7 @@ void GRenderWindow::InitRenderTarget() { core_context = CreateSharedContext(); resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); + OnFramebufferSizeChanged(); BackupGeometry(); } diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 23c33f627..44502858d 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -4,6 +4,7 @@ #include #include +#include "core/3ds.h" #include "core/frontend/emu_window.h" #include "core/frontend/input.h" #include "core/settings.h" @@ -45,7 +46,8 @@ private: EmuWindow::EmuWindow() { // TODO: Find a better place to set this. - config.min_client_area_size = std::make_pair(400u, 480u); + config.min_client_area_size = + std::make_pair(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); active_config = config; touch_state = std::make_shared(); Input::RegisterFactory("emu_window", touch_state); @@ -145,10 +147,16 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { Layout::FramebufferLayout layout; + const auto layout_option = Settings::values.layout_option; + const auto min_size = + Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen); + if (Settings::values.custom_layout == true) { layout = Layout::CustomFrameLayout(width, height); } else { - switch (Settings::values.layout_option) { + width = std::max(width, min_size.first); + height = std::max(height, min_size.second); + switch (layout_option) { case Settings::LayoutOption::SingleScreen: layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen, Settings::values.upright_screen); @@ -167,8 +175,16 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) Settings::values.upright_screen); break; } + UpdateMinimumWindowSize(min_size); } NotifyFramebufferLayoutChanged(layout); } +void EmuWindow::UpdateMinimumWindowSize(std::pair min_size) { + WindowConfig new_config = config; + new_config.min_client_area_size = min_size; + SetConfig(new_config); + ProcessConfigurationChanges(); +} + } // namespace Frontend diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index df6203842..efaa25d9f 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -180,7 +180,7 @@ protected: if (config.min_client_area_size != active_config.min_client_area_size) { OnMinimalClientAreaChangeRequest(config.min_client_area_size); - config.min_client_area_size = active_config.min_client_area_size; + active_config.min_client_area_size = config.min_client_area_size; } } @@ -215,6 +215,8 @@ private: * Clip the provided coordinates to be inside the touchscreen area. */ std::tuple ClipToTouchScreen(unsigned new_x, unsigned new_y) const; + + void UpdateMinimumWindowSize(std::pair min_size); }; } // namespace Frontend diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index cb7993271..71dce24be 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -363,4 +363,36 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { return layout; } +std::pair GetMinimumSizeFromLayout(Settings::LayoutOption layout, + bool upright_screen) { + unsigned min_width, min_height; + + switch (layout) { + case Settings::LayoutOption::SingleScreen: + min_width = Settings::values.swap_screen ? Core::kScreenBottomWidth : Core::kScreenTopWidth; + min_height = Core::kScreenBottomHeight; + break; + case Settings::LayoutOption::LargeScreen: + min_width = Settings::values.swap_screen + ? Core::kScreenTopWidth / 4 + Core::kScreenBottomWidth + : Core::kScreenTopWidth + Core::kScreenBottomWidth / 4; + min_height = Core::kScreenBottomHeight; + break; + case Settings::LayoutOption::SideScreen: + min_width = Core::kScreenTopWidth + Core::kScreenBottomWidth; + min_height = Core::kScreenBottomHeight; + break; + case Settings::LayoutOption::Default: + default: + min_width = Core::kScreenTopWidth; + min_height = Core::kScreenTopHeight + Core::kScreenBottomHeight; + break; + } + if (upright_screen) { + return std::make_pair(min_height, min_width); + } else { + return std::make_pair(min_width, min_height); + } +} + } // namespace Layout diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index 5feb16f64..ad3ff2724 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h @@ -5,6 +5,7 @@ #pragma once #include "common/math_util.h" +#include "core/settings.h" namespace Layout { @@ -80,4 +81,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height); */ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); +std::pair GetMinimumSizeFromLayout(Settings::LayoutOption layout, + bool upright_screen); + } // namespace Layout