mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-11-21 20:47:19 +01:00
Fixed bug 2808 - Fix SDL reporting wrong window size on resume
Jonas Kulla At startup time, the single android window is assigned a "windowed" (window->windowed.{w,h}) size based on the current orientation of the mobile device; this size is never updated throughout the lifetime of the app. This becomes problematic when the app is paused and then resumed in an orientation that it did not start up in. Eventually, 'SDL_OnWindowRestored()' is called, which calls 'SDL_UpdateFullscreenMode()'. This function is very problematic because it is written with a desktop monitor in mind: it tries to find a matching display mode for the windowed size, doesn't find any, and finally applies the windowed size as the fullscreen one. In the end, the windowed size is reported in a RESIZED event, which doesn't correspond to the actual surface size. To see this in action: Start an orientation aware SDL app in eg. portrait mode, suspend the app, put the device into landscape orientation and resume the app. It will erroneously render in portrait mode (until the device is rotated again).
This commit is contained in:
parent
5c1ab40302
commit
f674f2311a
@ -220,6 +220,15 @@ Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
|
||||
|
||||
if (Android_Window) {
|
||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||
|
||||
/* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
|
||||
* will fall back to the old mode */
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(Android_Window);
|
||||
|
||||
display->current_mode.format = format;
|
||||
display->current_mode.w = width;
|
||||
display->current_mode.h = height;
|
||||
display->current_mode.refresh_rate = rate;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user