[client,sdl] fix initial window size

* on high dpi displays set appropriate initial display size (divide
  pixel size with scale)
* send display resize on window resize events
* send display resize on any window event (minimize/maximize/expose/...)
This commit is contained in:
akallabeth
2025-03-26 20:01:44 +01:00
parent 99619b3392
commit 8d469feda0
2 changed files with 10 additions and 2 deletions

View File

@@ -358,10 +358,12 @@ BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev)
auto ctx = _sdl->context();
if (ctx && ctx->gdi)
gdi_send_suppress_output(ctx->gdi, FALSE);
return TRUE;
}
/* fallthrough */
WINPR_FALLTHROUGH
case SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED:
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
case SDL_EVENT_WINDOW_RESIZED:
{
if (freerdp_settings_get_bool(_sdl->context()->settings,
FreeRDP_DynamicResolutionUpdate))
@@ -370,7 +372,7 @@ BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev)
const auto factor = SDL_GetWindowDisplayScale(window.window());
_targetDesktopScaleFactor = static_cast<UINT32>(100 * factor);
}
assert(SDL_GetWindowSizeInPixels(it->second.window(), &_targetWidth, &_targetHeight));
SDL_GetWindowSizeInPixels(it->second.window(), &_targetWidth, &_targetHeight);
return addTimer();
}
case SDL_EVENT_WINDOW_MOUSE_LEAVE:

View File

@@ -33,6 +33,12 @@ SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY,
// SDL_SetProperty(props, SDL_PROP_WINDOW_CREATE_FL);
_window = SDL_CreateWindowWithProperties(props);
SDL_DestroyProperties(props);
auto scale = SDL_GetWindowPixelDensity(_window);
const int iscale = static_cast<int>(scale * 100.0f);
auto w = 100 * width / iscale;
auto h = 100 * height / iscale;
SDL_SetWindowSize(_window, w, h);
}
SdlWindow::SdlWindow(SdlWindow&& other) noexcept