src/video/android/SDL_androidwindow.c
changeset 12017 d8a165136edf
parent 12012 6de756c9975a
child 12255 d2e5d4520677
     1.1 --- a/src/video/android/SDL_androidwindow.c	Tue Jun 12 14:00:15 2018 +0300
     1.2 +++ b/src/video/android/SDL_androidwindow.c	Tue Jun 12 13:22:58 2018 -0700
     1.3 @@ -26,6 +26,7 @@
     1.4  #include "../SDL_sysvideo.h"
     1.5  #include "../../events/SDL_keyboard_c.h"
     1.6  #include "../../events/SDL_mouse_c.h"
     1.7 +#include "../../events/SDL_windowevents_c.h"
     1.8  
     1.9  #include "SDL_androidvideo.h"
    1.10  #include "SDL_androidwindow.h"
    1.11 @@ -101,6 +102,28 @@
    1.12  Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
    1.13  {
    1.14      Android_JNI_SetWindowStyle(fullscreen);
    1.15 +
    1.16 +    // Ensure our size matches reality after we've executed the window style change.
    1.17 +    //
    1.18 +    // It is possible that we've set width and height to the full-size display, but on
    1.19 +    // Samsung DeX or Chromebooks or other windowed Android environemtns, our window may 
    1.20 +    // still not be the full display size.
    1.21 +    //
    1.22 +    SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
    1.23 +
    1.24 +    if (!data || !data->native_window) {
    1.25 +        return;
    1.26 +    }
    1.27 +
    1.28 +    int old_w = window->w;
    1.29 +    int old_h = window->h;
    1.30 +
    1.31 +    int new_w = ANativeWindow_getWidth(data->native_window);
    1.32 +    int new_h = ANativeWindow_getHeight(data->native_window);
    1.33 +
    1.34 +    if (old_w != new_w || old_h != new_h) {
    1.35 +        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, new_w, new_h);
    1.36 +    }
    1.37  }
    1.38  
    1.39  void