On Android show the system UI when an SDL window is windowed, hide the system UI when it's fullscreen, like we do on iOS.

We're increasing the Android SDK minimum version to API 19, this doesn't increase the minimum target API, which is API 14.
This commit is contained in:
Sam Lantinga
2018-02-11 18:23:37 -08:00
parent 66f9492b69
commit 6e01fbb763
9 changed files with 66 additions and 29 deletions

View File

@@ -120,6 +120,7 @@ Android_CreateDevice(int devindex)
device->CreateSDLWindow = Android_CreateWindow;
device->SetWindowTitle = Android_SetWindowTitle;
device->SetWindowFullscreen = Android_SetWindowFullscreen;
device->DestroyWindow = Android_DestroyWindow;
device->GetWindowWMInfo = Android_GetWindowWMInfo;
@@ -220,7 +221,7 @@ Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
/*
Update the resolution of the desktop mode, so that the window
can be properly resized. The screen resolution change can for
example happen when the Activity enters or exists immersive mode,
example happen when the Activity enters or exits immersive mode,
which can happen after VideoInit().
*/
device = SDL_GetVideoDevice();
@@ -234,16 +235,17 @@ Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
}
if (Android_Window) {
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
/* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
* will fall back to the old mode */
display = SDL_GetDisplayForWindow(Android_Window);
display->current_mode.format = format;
display->current_mode.w = width;
display->current_mode.h = height;
display->current_mode.refresh_rate = rate;
display->display_modes[0].format = format;
display->display_modes[0].w = width;
display->display_modes[0].h = height;
display->display_modes[0].refresh_rate = rate;
display->current_mode = display->display_modes[0];
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
}
}

View File

@@ -53,7 +53,6 @@ Android_CreateWindow(_THIS, SDL_Window * window)
window->h = Android_ScreenHeight;
window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */
window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */
window->flags &= ~SDL_WINDOW_HIDDEN;
window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
@@ -98,6 +97,12 @@ Android_SetWindowTitle(_THIS, SDL_Window * window)
Android_JNI_SetActivityTitle(window->title);
}
void
Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
{
Android_JNI_SetWindowStyle(fullscreen);
}
void
Android_DestroyWindow(_THIS, SDL_Window * window)
{

View File

@@ -28,6 +28,7 @@
extern int Android_CreateWindow(_THIS, SDL_Window * window);
extern void Android_SetWindowTitle(_THIS, SDL_Window * window);
extern void Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern void Android_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo * info);