mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[client,sdl] ignore scale update if not connected
This commit is contained in:
@@ -1005,52 +1005,54 @@ static int sdl_run(SdlContext* sdl)
|
||||
switch (ev->type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED:
|
||||
{
|
||||
sdl_Pointer_Set_Process(sdl);
|
||||
if (freerdp_settings_get_bool(sdl->context()->settings,
|
||||
FreeRDP_DynamicResolutionUpdate))
|
||||
if (sdl->isConnected())
|
||||
{
|
||||
break;
|
||||
}
|
||||
auto win = window->second.window();
|
||||
int w_pix{};
|
||||
int h_pix{};
|
||||
[[maybe_unused]] auto rcpix =
|
||||
SDL_GetWindowSizeInPixels(win, &w_pix, &h_pix);
|
||||
assert(rcpix);
|
||||
auto scale = SDL_GetWindowDisplayScale(win);
|
||||
if (scale <= SDL_FLT_EPSILON)
|
||||
{
|
||||
auto err = SDL_GetError();
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowDisplayScale() failed with %s",
|
||||
err);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(SDL_isnanf(scale) == 0);
|
||||
assert(SDL_isinff(scale) == 0);
|
||||
assert(scale > SDL_FLT_EPSILON);
|
||||
auto w_gdi = sdl->context()->gdi->width;
|
||||
auto h_gdi = sdl->context()->gdi->height;
|
||||
auto pix2point = [=](int pix)
|
||||
sdl_Pointer_Set_Process(sdl);
|
||||
if (freerdp_settings_get_bool(
|
||||
sdl->context()->settings,
|
||||
FreeRDP_DynamicResolutionUpdate))
|
||||
{
|
||||
return static_cast<int>(static_cast<float>(pix) /
|
||||
scale);
|
||||
};
|
||||
if (w_pix != w_gdi || h_pix != h_gdi)
|
||||
break;
|
||||
}
|
||||
auto win = window->second.window();
|
||||
int w_pix{};
|
||||
int h_pix{};
|
||||
[[maybe_unused]] auto rcpix =
|
||||
SDL_GetWindowSizeInPixels(win, &w_pix, &h_pix);
|
||||
assert(rcpix);
|
||||
auto scale = SDL_GetWindowDisplayScale(win);
|
||||
if (scale <= SDL_FLT_EPSILON)
|
||||
{
|
||||
const auto ssws = SDL_SetWindowSize(
|
||||
win, pix2point(w_gdi), pix2point(h_gdi));
|
||||
if (!ssws)
|
||||
auto err = SDL_GetError();
|
||||
SDL_LogWarn(
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowDisplayScale() failed with %s", err);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(SDL_isnanf(scale) == 0);
|
||||
assert(SDL_isinff(scale) == 0);
|
||||
assert(scale > SDL_FLT_EPSILON);
|
||||
auto w_gdi = sdl->context()->gdi->width;
|
||||
auto h_gdi = sdl->context()->gdi->height;
|
||||
auto pix2point = [=](int pix)
|
||||
{
|
||||
auto err = SDL_GetError();
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_SetWindowSize() failed with %s",
|
||||
err);
|
||||
return static_cast<int>(static_cast<float>(pix) /
|
||||
scale);
|
||||
};
|
||||
if (w_pix != w_gdi || h_pix != h_gdi)
|
||||
{
|
||||
const auto ssws = SDL_SetWindowSize(
|
||||
win, pix2point(w_gdi), pix2point(h_gdi));
|
||||
if (!ssws)
|
||||
{
|
||||
auto err = SDL_GetError();
|
||||
SDL_LogWarn(
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_SetWindowSize() failed with %s", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
|
||||
Reference in New Issue
Block a user