[Commits] SDL: Ensure we wait on the surface resize before returning from ...

libsdl.org revision control commits-owner at libsdl.org
Fri Sep 28 20:40:09 PDT 2018


details:   https://hg.libsdl.org/SDL/rev/d2e5d4520677
changeset: 12255:d2e5d4520677
user:      Sam Lantinga <slouken at libsdl.org>
date:      Fri Sep 28 20:39:57 2018 -0700
description:
Ensure we wait on the surface resize before returning from setting fullscreen mode.

diffstat:

 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java |  21 +++++++++-
 src/core/android/SDL_android.h                                    |   5 ++
 src/video/android/SDL_androidwindow.c                             |   5 ++
 3 files changed, 30 insertions(+), 1 deletions(-)

diffs (82 lines):

diff -r f1ac9de30ee1 -r d2e5d4520677 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 01:24:10 2018 +0300
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Fri Sep 28 20:39:57 2018 -0700
@@ -643,7 +643,22 @@
         Message msg = commandHandler.obtainMessage();
         msg.arg1 = command;
         msg.obj = data;
-        return commandHandler.sendMessage(msg);
+        boolean result = commandHandler.sendMessage(msg);
+
+        // Ensure we don't return until the resize has actually happened,
+        // or 250ms have passed.
+        if (command == COMMAND_CHANGE_WINDOW_STYLE) {
+            synchronized(SDLActivity.getContext()) {
+                try {
+                    SDLActivity.getContext().wait(250);
+                }
+                catch (InterruptedException ie) {
+                    ie.printStackTrace();
+                }
+            }
+        }
+
+        return result;
     }
 
     // C functions we call
@@ -1577,6 +1592,10 @@
         }
         catch ( java.lang.Throwable throwable ) {}
 
+        synchronized(SDLActivity.getContext()) {
+            SDLActivity.getContext().notifyAll();
+        }
+
         Log.v("SDL", "Window size: " + width + "x" + height);
         Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
         SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
diff -r f1ac9de30ee1 -r d2e5d4520677 src/core/android/SDL_android.h
--- a/src/core/android/SDL_android.h	Sat Sep 29 01:24:10 2018 +0300
+++ b/src/core/android/SDL_android.h	Fri Sep 28 20:39:57 2018 -0700
@@ -19,6 +19,7 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 #include "../../SDL_internal.h"
+#include "SDL_system.h"
 
 /* Set up for C function definitions, even when using C++ */
 #ifdef __cplusplus
@@ -53,6 +54,10 @@
 extern void Android_JNI_FlushCapturedAudio(void);
 extern void Android_JNI_CloseAudioDevice(const int iscapture);
 
+/* Detecting device type */
+extern SDL_bool Android_IsDeXMode();
+extern SDL_bool Android_IsChromebook();
+
 #include "SDL_rwops.h"
 
 int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode);
diff -r f1ac9de30ee1 -r d2e5d4520677 src/video/android/SDL_androidwindow.c
--- a/src/video/android/SDL_androidwindow.c	Sat Sep 29 01:24:10 2018 +0300
+++ b/src/video/android/SDL_androidwindow.c	Fri Sep 28 20:39:57 2018 -0700
@@ -27,6 +27,7 @@
 #include "../../events/SDL_keyboard_c.h"
 #include "../../events/SDL_mouse_c.h"
 #include "../../events/SDL_windowevents_c.h"
+#include "../../core/android/SDL_android.h"
 
 #include "SDL_androidvideo.h"
 #include "SDL_androidwindow.h"
@@ -109,6 +110,10 @@
     // Samsung DeX or Chromebooks or other windowed Android environemtns, our window may 
     // still not be the full display size.
     //
+    if (!SDL_IsDeXMode() && !SDL_IsChromebook()) {
+        return;
+    }
+
     SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
 
     if (!data || !data->native_window) {


More information about the commits mailing list