mirror of https://github.com/libsdl-org/SDL
Android: add MinimizeWindow function (Bug 4580, 4657)
shouldMinimizeOnFocusLoss is un-activated (return false)
This commit is contained in:
parent
3f4e189b27
commit
f9a9193e2c
|
@ -846,6 +846,45 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by SDL using JNI.
|
||||||
|
*/
|
||||||
|
public static void minimizeWindow() {
|
||||||
|
|
||||||
|
if (mSingleton == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
||||||
|
startMain.addCategory(Intent.CATEGORY_HOME);
|
||||||
|
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mSingleton.startActivity(startMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by SDL using JNI.
|
||||||
|
*/
|
||||||
|
public static boolean shouldMinimizeOnFocusLoss() {
|
||||||
|
/*
|
||||||
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
|
if (mSingleton == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSingleton.isInMultiWindowMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSingleton.isInPictureInPictureMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -240,6 +240,8 @@ static jmethodID midSetSurfaceViewFormat;
|
||||||
static jmethodID midSetActivityTitle;
|
static jmethodID midSetActivityTitle;
|
||||||
static jmethodID midSetWindowStyle;
|
static jmethodID midSetWindowStyle;
|
||||||
static jmethodID midSetOrientation;
|
static jmethodID midSetOrientation;
|
||||||
|
static jmethodID midMinimizeWindow;
|
||||||
|
static jmethodID midShouldMinimizeOnFocusLoss;
|
||||||
static jmethodID midGetContext;
|
static jmethodID midGetContext;
|
||||||
static jmethodID midIsTablet;
|
static jmethodID midIsTablet;
|
||||||
static jmethodID midIsAndroidTV;
|
static jmethodID midIsAndroidTV;
|
||||||
|
@ -490,6 +492,10 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||||
"setWindowStyle","(Z)V");
|
"setWindowStyle","(Z)V");
|
||||||
midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass,
|
midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass,
|
||||||
"setOrientation","(IIZLjava/lang/String;)V");
|
"setOrientation","(IIZLjava/lang/String;)V");
|
||||||
|
midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass,
|
||||||
|
"minimizeWindow","()V");
|
||||||
|
midShouldMinimizeOnFocusLoss = (*env)->GetStaticMethodID(env, mActivityClass,
|
||||||
|
"shouldMinimizeOnFocusLoss","()Z");
|
||||||
midGetContext = (*env)->GetStaticMethodID(env, mActivityClass,
|
midGetContext = (*env)->GetStaticMethodID(env, mActivityClass,
|
||||||
"getContext","()Landroid/content/Context;");
|
"getContext","()Landroid/content/Context;");
|
||||||
midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass,
|
midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass,
|
||||||
|
@ -532,7 +538,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||||
|
|
||||||
|
|
||||||
if (!midGetNativeSurface || !midSetSurfaceViewFormat ||
|
if (!midGetNativeSurface || !midSetSurfaceViewFormat ||
|
||||||
!midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsTablet || !midIsAndroidTV || !midInitTouch ||
|
!midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midMinimizeWindow || !midShouldMinimizeOnFocusLoss || !midGetContext || !midIsTablet || !midIsAndroidTV || !midInitTouch ||
|
||||||
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
||||||
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
||||||
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
|
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
|
||||||
|
@ -1285,6 +1291,18 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
|
||||||
(*env)->DeleteLocalRef(env, jhint);
|
(*env)->DeleteLocalRef(env, jhint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Android_JNI_MinizeWindow()
|
||||||
|
{
|
||||||
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss()
|
||||||
|
{
|
||||||
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -39,6 +39,8 @@ extern "C" {
|
||||||
extern void Android_JNI_SetActivityTitle(const char *title);
|
extern void Android_JNI_SetActivityTitle(const char *title);
|
||||||
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
|
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
|
||||||
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
|
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
|
||||||
|
extern void Android_JNI_MinizeWindow(void);
|
||||||
|
extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
|
||||||
|
|
||||||
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
|
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
|
||||||
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
|
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
|
||||||
|
|
|
@ -2664,6 +2664,15 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
{
|
||||||
|
extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
|
||||||
|
if (! Android_JNI_ShouldMinimizeOnFocusLoss()) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
|
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ Android_CreateDevice(int devindex)
|
||||||
device->CreateSDLWindow = Android_CreateWindow;
|
device->CreateSDLWindow = Android_CreateWindow;
|
||||||
device->SetWindowTitle = Android_SetWindowTitle;
|
device->SetWindowTitle = Android_SetWindowTitle;
|
||||||
device->SetWindowFullscreen = Android_SetWindowFullscreen;
|
device->SetWindowFullscreen = Android_SetWindowFullscreen;
|
||||||
|
device->MinimizeWindow = Android_MinimizeWindow;
|
||||||
device->DestroyWindow = Android_DestroyWindow;
|
device->DestroyWindow = Android_DestroyWindow;
|
||||||
device->GetWindowWMInfo = Android_GetWindowWMInfo;
|
device->GetWindowWMInfo = Android_GetWindowWMInfo;
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,12 @@ endfunction:
|
||||||
SDL_UnlockMutex(Android_ActivityMutex);
|
SDL_UnlockMutex(Android_ActivityMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Android_MinimizeWindow(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
Android_JNI_MinizeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Android_DestroyWindow(_THIS, SDL_Window *window)
|
Android_DestroyWindow(_THIS, SDL_Window *window)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
extern int Android_CreateWindow(_THIS, SDL_Window *window);
|
extern int Android_CreateWindow(_THIS, SDL_Window *window);
|
||||||
extern void Android_SetWindowTitle(_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_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
|
||||||
|
extern void Android_MinimizeWindow(_THIS, SDL_Window *window);
|
||||||
|
|
||||||
extern void Android_DestroyWindow(_THIS, SDL_Window *window);
|
extern void Android_DestroyWindow(_THIS, SDL_Window *window);
|
||||||
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
|
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
|
||||||
extern SDL_Window *Android_Window;
|
extern SDL_Window *Android_Window;
|
||||||
|
|
Loading…
Reference in New Issue