mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-17 14:47:19 +01:00
emscripten: force resize event when pixel ratio changes
Without this, applications can't react to changed canvas size on window zoom.
This commit is contained in:
parent
b8bd0aa0bd
commit
6311c7cf95
@ -586,10 +586,14 @@ static EM_BOOL
|
|||||||
Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
|
Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
|
||||||
{
|
{
|
||||||
SDL_WindowData *window_data = userData;
|
SDL_WindowData *window_data = userData;
|
||||||
|
SDL_bool force = SDL_FALSE;
|
||||||
|
|
||||||
/* update pixel ratio */
|
/* update pixel ratio */
|
||||||
if (window_data->window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
if (window_data->window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
|
if (window_data->pixel_ratio != emscripten_get_device_pixel_ratio()) {
|
||||||
window_data->pixel_ratio = emscripten_get_device_pixel_ratio();
|
window_data->pixel_ratio = emscripten_get_device_pixel_ratio();
|
||||||
|
force = SDL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(window_data->window->flags & FULLSCREEN_MASK))
|
if(!(window_data->window->flags & FULLSCREEN_MASK))
|
||||||
@ -611,6 +615,12 @@ Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *u
|
|||||||
emscripten_set_element_css_size(NULL, w, h);
|
emscripten_set_element_css_size(NULL, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force) {
|
||||||
|
/* force the event to trigger, so pixel ratio changes can be handled */
|
||||||
|
window_data->window->w = 0;
|
||||||
|
window_data->window->h = 0;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user