src/video/android/SDL_androidvideo.c
changeset 10438 f7d8e9d871c5
parent 10051 2c6c612344b5
child 10475 82f21f6121db
     1.1 --- a/src/video/android/SDL_androidvideo.c	Sat Oct 01 14:16:04 2016 -0700
     1.2 +++ b/src/video/android/SDL_androidvideo.c	Sat Oct 01 14:18:29 2016 -0700
     1.3 @@ -194,7 +194,6 @@
     1.4      Android_QuitTouch();
     1.5  }
     1.6  
     1.7 -/* This function gets called before VideoInit() */
     1.8  void
     1.9  Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
    1.10  {
    1.11 @@ -203,6 +202,22 @@
    1.12      Android_ScreenFormat = format;
    1.13      Android_ScreenRate = rate;
    1.14  
    1.15 +    /*
    1.16 +      Update the resolution of the desktop mode, so that the window
    1.17 +      can be properly resized. The screen resolution change can for
    1.18 +      example happen when the Activity enters or exists immersive mode,
    1.19 +      which can happen after VideoInit().
    1.20 +    */
    1.21 +    SDL_VideoDevice* device = SDL_GetVideoDevice();
    1.22 +    if (device && device->num_displays > 0)
    1.23 +    {
    1.24 +        SDL_VideoDisplay* display = &device->displays[0];
    1.25 +        display->desktop_mode.format = Android_ScreenFormat;
    1.26 +        display->desktop_mode.w = Android_ScreenWidth;
    1.27 +        display->desktop_mode.h = Android_ScreenHeight;
    1.28 +        display->desktop_mode.refresh_rate  = Android_ScreenRate;
    1.29 +    }
    1.30 +
    1.31      if (Android_Window) {
    1.32          SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
    1.33      }