Skip to content

Commit c7614a7

Browse files
committed
sdl: correctly send a resize event if the orientation of the screen changed + force the exposure of the window. This will trigger a new frame drawing, then window will be resized.
Tested with --orientation sensor on showcase example.
1 parent fbc4cdd commit c7614a7

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/jni/sdl/src/video/android/SDL_androidvideo.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,31 @@ void SDL_ANDROID_WaitForResume()
9797
JNIEXPORT void JNICALL
9898
JAVA_EXPORT_NAME(SDLSurfaceView_nativeResize) ( JNIEnv* env, jobject thiz, jint w, jint h )
9999
{
100+
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d", w, h);
101+
100102
SDL_ANDROID_sWindowWidth = w;
101103
SDL_ANDROID_sWindowHeight = h;
102-
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d", w, h);
104+
}
105+
106+
107+
JNIEXPORT void JNICALL
108+
JAVA_EXPORT_NAME(SDLSurfaceView_nativeResizeEvent) ( JNIEnv* env, jobject thiz, jint w, jint h)
109+
{
110+
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Private resize to %dx%d", w, h);
111+
SDL_PrivateResize(w, h);
112+
SDL_ANDROID_sWindowWidth = w;
113+
SDL_ANDROID_sWindowHeight = h;
114+
if ( SDL_VideoSurface ) {
115+
SDL_VideoSurface->w = w;
116+
SDL_VideoSurface->h = h;
117+
}
118+
}
119+
120+
121+
JNIEXPORT void JNICALL
122+
JAVA_EXPORT_NAME(SDLSurfaceView_nativeExpose) ( JNIEnv* env, jobject thiz, jint w, jint h)
123+
{
124+
SDL_PrivateExpose();
103125
}
104126

105127
JNIEXPORT void JNICALL

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
543543
new Thread(this).start();
544544
} else {
545545
mChanged = true;
546+
nativeExpose();
546547
}
547548
}
548549

@@ -845,7 +846,10 @@ public boolean createSurface() {
845846
}
846847

847848
if (mStarted) {
848-
nativeResize(mWidth, mHeight);
849+
if (mInputActivated)
850+
nativeResizeEvent(mWidth, mHeight);
851+
else
852+
nativeResize(mWidth, mHeight);
849853
}
850854

851855
return true;
@@ -1165,6 +1169,8 @@ private void checkGlError(String op) {
11651169
public static native void nativeSetMultitouchUsed();
11661170

11671171
public native void nativeResize(int width, int height);
1172+
public native void nativeResizeEvent(int width, int height);
1173+
public native void nativeExpose();
11681174
public native void nativeInitJavaCallbacks();
11691175

11701176
}

0 commit comments

Comments
 (0)