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