mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user