aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheofficialhackclean <85363951+theofficialhackclean@users.noreply.github.com>2026-10-29 15:16:27 -0400
committertheofficialhackclean <85363951+theofficialhackclean@users.noreply.github.com>2026-10-29 15:16:27 -0400
commit50c9fd3471d5f0170a7495ee10fd8b0b2f0298e1 (patch)
tree19c0e51f5d82fe77e04ee46b0700936b58efb328
parenta8657997e1eb594ffde9e28d44672ef5b697ad59 (diff)
fixed window size for mkw
-rw-r--r--src/core/hle/service/nx2_gsv.h24
-rw-r--r--src/yuzu/bootmanager.cpp7
-rw-r--r--src/yuzu/main_window.cpp40
3 files changed, 63 insertions, 8 deletions
diff --git a/src/core/hle/service/nx2_gsv.h b/src/core/hle/service/nx2_gsv.h
index fb1436bd5e..926bfa5809 100644
--- a/src/core/hle/service/nx2_gsv.h
+++ b/src/core/hle/service/nx2_gsv.h
@@ -929,6 +929,28 @@ private:
image_id, address);
return;
}
+ u32 crop_width = layout.width;
+ u32 crop_height = layout.height;
+ if (layout.width == 3840 && layout.height == 2160) {
+ crop_width = 2560;
+ crop_height = 1440;
+ }
+ static const u32 env_crop_w = [] {
+ const char* v = std::getenv("EDEN_NX2_CROP_WIDTH");
+ return v ? static_cast<u32>(std::strtoul(v, nullptr, 10)) : 0U;
+ }();
+ static const u32 env_crop_h = [] {
+ const char* v = std::getenv("EDEN_NX2_CROP_HEIGHT");
+ return v ? static_cast<u32>(std::strtoul(v, nullptr, 10)) : 0U;
+ }();
+ if (env_crop_w != 0 && env_crop_h != 0) {
+ crop_width = env_crop_w;
+ crop_height = env_crop_h;
+ }
+ if (m_presents <= 4) {
+ LOG_INFO(Service, "nx2:vi2 composite image {} layout {}x{}, crop {}x{}",
+ image_id, layout.width, layout.height, crop_width, crop_height);
+ }
std::vector<Tegra::FramebufferConfig> layers{Tegra::FramebufferConfig{
.address = *device,
.offset = 0,
@@ -937,7 +959,7 @@ private:
.stride = static_cast<u32>(layout.pitch / 4),
.pixel_format = android::PixelFormat::Rgba8888,
.transform_flags = android::BufferTransformFlags::Unset,
- .crop_rect = {0, 0, static_cast<int>(layout.width), static_cast<int>(layout.height)},
+ .crop_rect = {0, 0, static_cast<int>(crop_width), static_cast<int>(crop_height)},
.blending = Tegra::BlendMode::Opaque,
.native_tiling = true,
}};
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 57cc395ae8..7b68e0761b 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -764,12 +764,15 @@ bool GRenderWindow::InitRenderTarget() {
// Update the Window System information with the new render target
window_info = QtCommon::GetWindowSystemInfo(child_widget->windowHandle());
- child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
+ const auto target_width = Settings::IsDockedMode() ? Layout::ScreenDocked::Width : Layout::ScreenUndocked::Width;
+ const auto target_height = Settings::IsDockedMode() ? Layout::ScreenDocked::Height : Layout::ScreenUndocked::Height;
+
+ child_widget->resize(target_width, target_height);
layout()->addWidget(child_widget);
// Reset minimum required size to avoid resizing issues on the main window after restarting.
setMinimumSize(1, 1);
- resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
+ resize(target_width, target_height);
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
OnFramebufferSizeChanged();
diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp
index f19b827a32..38fa28b80f 100644
--- a/src/yuzu/main_window.cpp
+++ b/src/yuzu/main_window.cpp
@@ -2049,6 +2049,12 @@ void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletPa
emulation_running = true;
if (ui->action_Fullscreen->isChecked()) {
ShowFullscreen();
+ } else {
+ if (Settings::IsDockedMode()) {
+ ResetWindowSize1080();
+ } else {
+ ResetWindowSize720();
+ }
}
OnStartGame();
}
@@ -3311,12 +3317,36 @@ void MainWindow::ToggleWindowMode() {
void MainWindow::ResetWindowSize(u32 width, u32 height) {
const auto aspect_ratio = Layout::EmulationAspectRatio(Settings::values.aspect_ratio.GetValue(),
float(height) / width);
- if (!ui->action_Single_Window_Mode->isChecked()) {
- render_window->resize(height / aspect_ratio, height);
+ const bool single_window = ui->action_Single_Window_Mode->isChecked();
+ const bool show_status_bar = ui->action_Show_Status_Bar->isChecked();
+ const auto status_bar_height = (single_window && show_status_bar) ? statusBar()->height() : 0;
+ const auto menu_bar_height = single_window ? menuBar()->height() : 0;
+ const auto extra_height = menu_bar_height + status_bar_height;
+
+ auto* current_screen = this->screen();
+ if (!current_screen) {
+ current_screen = QGuiApplication::primaryScreen();
+ }
+ const auto available = current_screen ? current_screen->availableGeometry() : QRect();
+
+ u32 target_h = height;
+ u32 target_w = static_cast<u32>(std::round(height / aspect_ratio));
+
+ if (!available.isEmpty()) {
+ const int max_w = available.width();
+ const int max_h = available.height() - extra_height;
+ if (max_w > 0 && max_h > 0 &&
+ (target_w > static_cast<u32>(max_w) || target_h > static_cast<u32>(max_h))) {
+ const float scale = (std::min)(float(max_w) / target_w, float(max_h) / target_h);
+ target_w = (std::max)(1U, static_cast<u32>(std::round(target_w * scale)));
+ target_h = (std::max)(1U, static_cast<u32>(std::round(target_h * scale)));
+ }
+ }
+
+ if (!single_window) {
+ render_window->resize(target_w, target_h);
} else {
- const bool show_status_bar = ui->action_Show_Status_Bar->isChecked();
- const auto status_bar_height = show_status_bar ? statusBar()->height() : 0;
- resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height);
+ resize(target_w, target_h + extra_height);
}
}