From dec4c8533c252f29d90ad6598409305145f28c11 Mon Sep 17 00:00:00 2001 From: "A.J. Ruckman" Date: Sun, 28 Mar 2021 15:28:56 -0400 Subject: [PATCH] [client] win: add new option win:shrinkOnUpscale This option constrains the client's window dimensions to the guest's resolution when 'dontUpscale' is also enabled --- client/README.md | 1 + client/src/config.c | 8 ++++++++ client/src/core.c | 14 ++++++++++++++ client/src/main.h | 1 + 4 files changed, 24 insertions(+) diff --git a/client/README.md b/client/README.md index ea82148d..bc94bc0c 100644 --- a/client/README.md +++ b/client/README.md @@ -126,6 +126,7 @@ Command line arguments will override any options loaded from the config files. | win:keepAspect | -r | yes | Maintain the correct aspect ratio | | win:forceAspect | | yes | Force the window to maintain the aspect ratio | | win:dontUpscale | | no | Never try to upscale the window | +| win:shrinkOnUpscale | | no | Limit the window dimensions when dontUpscale is enabled | | win:borderless | -d | no | Borderless mode | | win:fullScreen | -F | no | Launch in fullscreen borderless mode | | win:maximize | -T | no | Launch window maximized | diff --git a/client/src/config.c b/client/src/config.c index ff80d1a7..b7f5ed45 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -161,6 +161,13 @@ static struct Option options[] = .type = OPTION_TYPE_BOOL, .value.x_bool = false, }, + { + .module = "win", + .name = "shrinkOnUpscale", + .description = "Limit the window dimensions when dontUpscale is enabled", + .type = OPTION_TYPE_BOOL, + .value.x_bool = false, + }, { .module = "win", .name = "borderless", @@ -500,6 +507,7 @@ bool config_load(int argc, char * argv[]) g_params.keepAspect = option_get_bool ("win", "keepAspect" ); g_params.forceAspect = option_get_bool ("win", "forceAspect" ); g_params.dontUpscale = option_get_bool ("win", "dontUpscale" ); + g_params.shrinkOnUpscale = option_get_bool ("win", "shrinkOnUpscale"); g_params.borderless = option_get_bool ("win", "borderless" ); g_params.fullscreen = option_get_bool ("win", "fullScreen" ); g_params.maximize = option_get_bool ("win", "maximize" ); diff --git a/client/src/core.c b/client/src/core.c index 4fab406f..8505f65f 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -238,6 +238,20 @@ void core_updatePositionInfo(void) g_state.dstRect.y = (g_state.windowH >> 1) - (g_state.dstRect.h >> 1); } + if (g_params.dontUpscale && g_params.shrinkOnUpscale) + { + if (g_state.windowW > srcW) + { + force = true; + g_state.dstRect.w = srcW; + } + if (g_state.windowH > srcH) + { + force = true; + g_state.dstRect.h = srcH; + } + } + if (force && g_params.forceAspect) { g_state.resizeTimeout = microtime() + RESIZE_TIMEOUT; diff --git a/client/src/main.h b/client/src/main.h index 29faa0f5..951a03a2 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -106,6 +106,7 @@ struct AppParams bool keepAspect; bool forceAspect; bool dontUpscale; + bool shrinkOnUpscale; bool borderless; bool fullscreen; bool maximize;