From 14c66c8bfce46d5f3093f374ef2d33e97736d6cd Mon Sep 17 00:00:00 2001 From: "Morgan J." Date: Fri, 13 Feb 2026 12:22:13 +0900 Subject: [PATCH] [client,SDL] Fix properly handle smart-sizing * In fullscreen set desktop resolution to argument provided with /smart-sizing:x * In window mode set the window size to /size:x and the remote resolution to /smart-sizing:x * Ignore and print a warning if /multimon is in use (currently not defined) --- client/SDL/SDL3/sdl_context.cpp | 42 +++++++++++++++++++++++++++++---- client/SDL/SDL3/sdl_context.hpp | 2 ++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/client/SDL/SDL3/sdl_context.cpp b/client/SDL/SDL3/sdl_context.cpp index 2b78c531e..3f2328c46 100644 --- a/client/SDL/SDL3/sdl_context.cpp +++ b/client/SDL/SDL3/sdl_context.cpp @@ -173,6 +173,33 @@ BOOL SdlContext::preConnect(freerdp* instance) if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, maxHeight)) return FALSE; } + + /** + * If /f is specified in combination with /smart-sizing:widthxheight then + * we run the session in the /smart-sizing dimensions scaled to full screen + */ + + const uint32_t sw = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); + const uint32_t sh = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); + const BOOL sm = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing); + if (sm && (sw > 0) && (sh > 0)) + { + const BOOL mm = freerdp_settings_get_bool(settings, FreeRDP_UseMultimon); + if (mm) + WLog_Print(sdl->getWLog(), WLOG_WARN, + "/smart-sizing and /multimon are currently not supported, ignoring " + "/smart-sizing!"); + else + { + sdl->_windowWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + sdl->_windowHeigth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, sw)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, sh)) + return FALSE; + } + } } else { @@ -387,13 +414,20 @@ bool SdlContext::createWindows() auto monitor = static_cast( freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, x)); - auto w = WINPR_ASSERTING_INT_CAST(Uint32, monitor->width); - auto h = WINPR_ASSERTING_INT_CAST(Uint32, monitor->height); + Uint32 w = WINPR_ASSERTING_INT_CAST(Uint32, monitor->width); + Uint32 h = WINPR_ASSERTING_INT_CAST(Uint32, monitor->height); if (!(freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))) { - w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); - h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + if (_windowWidth > 0) + w = _windowWidth; + else + w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + + if (_windowHeigth > 0) + h = _windowHeigth; + else + h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); } Uint32 flags = SDL_WINDOW_HIGH_PIXEL_DENSITY; diff --git a/client/SDL/SDL3/sdl_context.hpp b/client/SDL/SDL3/sdl_context.hpp index 25f82e60e..2110c4e30 100644 --- a/client/SDL/SDL3/sdl_context.hpp +++ b/client/SDL/SDL3/sdl_context.hpp @@ -208,6 +208,8 @@ class SdlContext std::map _windows; + uint32_t _windowWidth = 0; + uint32_t _windowHeigth = 0; WinPREvent _windowsCreatedEvent; std::thread _thread; };