Ensure we wait on the surface resize before returning from setting fullscreen mode.
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Sep 2018 20:39:57 -0700
changeset 12255d2e5d4520677
parent 12254 f1ac9de30ee1
child 12256 9f3949b8ec40
Ensure we wait on the surface resize before returning from setting fullscreen mode.
Xcode/SDL/SDL.xcodeproj/project.pbxproj
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
src/core/android/SDL_android.h
src/video/android/SDL_androidwindow.c
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 01:24:10 2018 +0300
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Fri Sep 28 20:39:57 2018 -0700
     1.3 @@ -643,7 +643,22 @@
     1.4          Message msg = commandHandler.obtainMessage();
     1.5          msg.arg1 = command;
     1.6          msg.obj = data;
     1.7 -        return commandHandler.sendMessage(msg);
     1.8 +        boolean result = commandHandler.sendMessage(msg);
     1.9 +
    1.10 +        // Ensure we don't return until the resize has actually happened,
    1.11 +        // or 250ms have passed.
    1.12 +        if (command == COMMAND_CHANGE_WINDOW_STYLE) {
    1.13 +            synchronized(SDLActivity.getContext()) {
    1.14 +                try {
    1.15 +                    SDLActivity.getContext().wait(250);
    1.16 +                }
    1.17 +                catch (InterruptedException ie) {
    1.18 +                    ie.printStackTrace();
    1.19 +                }
    1.20 +            }
    1.21 +        }
    1.22 +
    1.23 +        return result;
    1.24      }
    1.25  
    1.26      // C functions we call
    1.27 @@ -1577,6 +1592,10 @@
    1.28          }
    1.29          catch ( java.lang.Throwable throwable ) {}
    1.30  
    1.31 +        synchronized(SDLActivity.getContext()) {
    1.32 +            SDLActivity.getContext().notifyAll();
    1.33 +        }
    1.34 +
    1.35          Log.v("SDL", "Window size: " + width + "x" + height);
    1.36          Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
    1.37          SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
     2.1 --- a/src/core/android/SDL_android.h	Sat Sep 29 01:24:10 2018 +0300
     2.2 +++ b/src/core/android/SDL_android.h	Fri Sep 28 20:39:57 2018 -0700
     2.3 @@ -19,6 +19,7 @@
     2.4    3. This notice may not be removed or altered from any source distribution.
     2.5  */
     2.6  #include "../../SDL_internal.h"
     2.7 +#include "SDL_system.h"
     2.8  
     2.9  /* Set up for C function definitions, even when using C++ */
    2.10  #ifdef __cplusplus
    2.11 @@ -53,6 +54,10 @@
    2.12  extern void Android_JNI_FlushCapturedAudio(void);
    2.13  extern void Android_JNI_CloseAudioDevice(const int iscapture);
    2.14  
    2.15 +/* Detecting device type */
    2.16 +extern SDL_bool Android_IsDeXMode();
    2.17 +extern SDL_bool Android_IsChromebook();
    2.18 +
    2.19  #include "SDL_rwops.h"
    2.20  
    2.21  int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode);
     3.1 --- a/src/video/android/SDL_androidwindow.c	Sat Sep 29 01:24:10 2018 +0300
     3.2 +++ b/src/video/android/SDL_androidwindow.c	Fri Sep 28 20:39:57 2018 -0700
     3.3 @@ -27,6 +27,7 @@
     3.4  #include "../../events/SDL_keyboard_c.h"
     3.5  #include "../../events/SDL_mouse_c.h"
     3.6  #include "../../events/SDL_windowevents_c.h"
     3.7 +#include "../../core/android/SDL_android.h"
     3.8  
     3.9  #include "SDL_androidvideo.h"
    3.10  #include "SDL_androidwindow.h"
    3.11 @@ -109,6 +110,10 @@
    3.12      // Samsung DeX or Chromebooks or other windowed Android environemtns, our window may 
    3.13      // still not be the full display size.
    3.14      //
    3.15 +    if (!SDL_IsDeXMode() && !SDL_IsChromebook()) {
    3.16 +        return;
    3.17 +    }
    3.18 +
    3.19      SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
    3.20  
    3.21      if (!data || !data->native_window) {