Fix the problem that Surface size may get wrong after Android backend cut to frontend (#255)

This commit is contained in:
bofeng-song 2022-05-13 10:16:01 +08:00 committed by GitHub
parent c90cf22abf
commit 9a6b364f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -767,10 +767,15 @@ static void onSurfaceChanged_native(JNIEnv *env, jobject javaGameActivity,
code->nativeWindow); code->nativeWindow);
} }
code->lastWindowWidth = if (width != code->lastWindowWidth ||
ANativeWindow_getWidth(code->nativeWindow); height != code->lastWindowHeight) {
code->lastWindowHeight = code->lastWindowWidth = width;
ANativeWindow_getHeight(code->nativeWindow); code->lastWindowHeight = height;
if (code->callbacks.onNativeWindowResized != NULL) {
code->callbacks.onNativeWindowResized(
code, code->nativeWindow, width, height);
}
}
} }
} else { } else {
// Maybe it was resized? // Maybe it was resized?
@ -778,6 +783,8 @@ static void onSurfaceChanged_native(JNIEnv *env, jobject javaGameActivity,
int32_t newHeight = ANativeWindow_getHeight(code->nativeWindow); int32_t newHeight = ANativeWindow_getHeight(code->nativeWindow);
if (newWidth != code->lastWindowWidth || if (newWidth != code->lastWindowWidth ||
newHeight != code->lastWindowHeight) { newHeight != code->lastWindowHeight) {
code->lastWindowWidth = newWidth;
code->lastWindowHeight = newHeight;
if (code->callbacks.onNativeWindowResized != NULL) { if (code->callbacks.onNativeWindowResized != NULL) {
code->callbacks.onNativeWindowResized( code->callbacks.onNativeWindowResized(
code, code->nativeWindow, newWidth, newHeight); code, code->nativeWindow, newWidth, newHeight);