Skip to content

Commit

Permalink
Android: prevent a dummy error message sending SDL_DISPLAYEVENT_ORIEN…
Browse files Browse the repository at this point in the history
…TATION

In the usual case, first call to onNativeOrientationChanged() is done before
SDL has been initialised and would just set an error message
"Video subsystem has not been initialized" without sending the event.
  • Loading branch information
1bsyl committed Jan 9, 2019
1 parent 02f292e commit 8dd9155
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -260,6 +260,7 @@ public void onClick(DialogInterface dialog,int id) {

// Get our current screen orientation and pass it down.
mCurrentOrientation = SDLActivity.getCurrentOrientation();
// FIXME: with only one activity, SDL Thread is not yet started and this onNativeOrientationChanged() is ignored
SDLActivity.onNativeOrientationChanged(mCurrentOrientation);

setContentView(mLayout);
Expand Down
7 changes: 5 additions & 2 deletions src/core/android/SDL_android.c
Expand Up @@ -583,8 +583,11 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
JNIEnv *env, jclass jcls,
jint orientation)
{
SDL_VideoDisplay *display = SDL_GetDisplay(0);
SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this) {
SDL_VideoDisplay *display = SDL_GetDisplay(0);
SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
}
}

/* Paddown */
Expand Down

0 comments on commit 8dd9155

Please sign in to comment.