From b881e1989688c6e6344196f95cd31fff91a3243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Ky=C3=B6stil=C3=A4?= Date: Wed, 31 Jul 2024 02:00:43 +1000 Subject: [PATCH] android: Update window/surface pointers on change When the native window or surface backing the SDL window changes, e.g., when the activity is resumed, we should also update the corresponding window pointer properties (SDL_PROP_WINDOW_ANDROID_{WINDOW,SURFACE} _POINTER) so that they remain in sync. --- src/core/android/SDL_android.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 6c38308daa..cc096924f7 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -1211,6 +1211,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, j SDL_WindowData *data = Android_Window->internal; data->native_window = Android_JNI_GetNativeWindow(); + SDL_SetPointerProperty(SDL_GetWindowProperties(Android_Window), SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER, data->native_window); if (data->native_window == NULL) { SDL_SetError("Could not fetch native window from UI thread"); } @@ -1232,6 +1233,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ if (data->egl_surface == EGL_NO_SURFACE) { data->egl_surface = SDL_EGL_CreateSurface(_this, Android_Window, (NativeWindowType)data->native_window); + SDL_SetPointerProperty(SDL_GetWindowProperties(Android_Window), SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER, data->egl_surface); } /* GL Context handling is done in the event loop because this function is run from the Java thread */