Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure we wait on the surface resize before returning from setting fu…
…llscreen mode.
  • Loading branch information
slouken committed Sep 29, 2018
1 parent 31596f2 commit 74638ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Empty file modified Xcode/SDL/SDL.xcodeproj/project.pbxproj 100644 → 100755
Empty file.
Expand Up @@ -643,7 +643,22 @@ boolean sendCommand(int command, Object data) {
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
Expand Down Expand Up @@ -1577,6 +1592,10 @@ public void surfaceChanged(SurfaceHolder holder,
}
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());
Expand Down
5 changes: 5 additions & 0 deletions src/core/android/SDL_android.h
Expand Up @@ -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
Expand Down Expand Up @@ -53,6 +54,10 @@ extern int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen);
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);
Expand Down
5 changes: 5 additions & 0 deletions src/video/android/SDL_androidwindow.c
Expand Up @@ -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"
Expand Down Expand Up @@ -109,6 +110,10 @@ Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displ
// 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) {
Expand Down

0 comments on commit 74638ea

Please sign in to comment.