mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-26 16:18:57 +00:00
emscripten: Send resize events when screen orientation changes.
The canvas _might_ be changing sizes, if you've set up your own CSS for it, or are using SDL_HINT_EMSCRIPTEN_FILL_DOCUMENT. Reference Issue #7359.
This commit is contained in:
@@ -612,6 +612,19 @@ static EM_BOOL Emscripten_HandleOrientationChange(int eventType, const Emscripte
|
||||
SDL_WindowData *window_data = (SDL_WindowData *) userData;
|
||||
SDL_SendDisplayEvent(SDL_GetVideoDisplayForWindow(window_data->window), SDL_EVENT_DISPLAY_ORIENTATION, orientation, 0);
|
||||
|
||||
// fake a UI event so we can tell the app the canvas might have resized.
|
||||
EmscriptenUiEvent uiEvent;
|
||||
SDL_zero(uiEvent);
|
||||
uiEvent.documentBodyClientWidth = MAIN_THREAD_EM_ASM_INT( { return document.body.clientWidth; } );
|
||||
uiEvent.documentBodyClientHeight = MAIN_THREAD_EM_ASM_INT( { return document.body.clientHeight; } );
|
||||
uiEvent.windowInnerWidth = MAIN_THREAD_EM_ASM_INT( { return window.innerWidth; } );
|
||||
uiEvent.windowInnerHeight = MAIN_THREAD_EM_ASM_INT( { return window.innerHeight; } );
|
||||
uiEvent.windowOuterWidth = MAIN_THREAD_EM_ASM_INT( { return window.outerWidth; } );
|
||||
uiEvent.windowOuterHeight = MAIN_THREAD_EM_ASM_INT( { return window.outerHeight; } );
|
||||
uiEvent.scrollTop = MAIN_THREAD_EM_ASM_INT( { return window.pageXOffset; } );
|
||||
uiEvent.scrollLeft = MAIN_THREAD_EM_ASM_INT( { return window.pageYOffset; } );
|
||||
Emscripten_HandleResize(EMSCRIPTEN_EVENT_RESIZE, &uiEvent, userData);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user