Keep track of whether the Android on-screen keyboard was opened by the application
Fixes https://github.com/libsdl-org/SDL/issues/9202
(cherry picked from commit edbcef11ff
)
This commit is contained in:
parent
75c5cff0bf
commit
bdc7ad8f56
3 changed files with 14 additions and 8 deletions
|
@ -150,10 +150,7 @@ void Android_PumpEvents_Blocking(_THIS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
||||||
if (SDL_IsTextInputActive() &&
|
Android_RestoreScreenKeyboardOnResume(_this, Android_Window);
|
||||||
SDL_GetHintBoolean(SDL_HINT_ENABLE_SCREEN_KEYBOARD, SDL_TRUE)) {
|
|
||||||
Android_ShowScreenKeyboard(_this, Android_Window); /* Only showTextInput */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
|
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
|
||||||
|
@ -235,10 +232,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
||||||
if (SDL_IsTextInputActive() &&
|
Android_RestoreScreenKeyboardOnResume(_this, Android_Window);
|
||||||
SDL_GetHintBoolean(SDL_HINT_ENABLE_SCREEN_KEYBOARD, SDL_TRUE)) {
|
|
||||||
Android_ShowScreenKeyboard(_this, Android_Window); /* Only showTextInput */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
|
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
|
||||||
|
|
|
@ -313,6 +313,8 @@ static SDL_Scancode Android_Keycodes[] = {
|
||||||
SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */
|
SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static SDL_bool SDL_screen_keyboard_shown;
|
||||||
|
|
||||||
static SDL_Scancode TranslateKeycode(int keycode)
|
static SDL_Scancode TranslateKeycode(int keycode)
|
||||||
{
|
{
|
||||||
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
|
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
|
||||||
|
@ -345,11 +347,20 @@ void Android_ShowScreenKeyboard(_THIS, SDL_Window *window)
|
||||||
{
|
{
|
||||||
SDL_VideoData *videodata = _this->driverdata;
|
SDL_VideoData *videodata = _this->driverdata;
|
||||||
Android_JNI_ShowScreenKeyboard(&videodata->textRect);
|
Android_JNI_ShowScreenKeyboard(&videodata->textRect);
|
||||||
|
SDL_screen_keyboard_shown = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Android_HideScreenKeyboard(_THIS, SDL_Window *window)
|
void Android_HideScreenKeyboard(_THIS, SDL_Window *window)
|
||||||
{
|
{
|
||||||
Android_JNI_HideScreenKeyboard();
|
Android_JNI_HideScreenKeyboard();
|
||||||
|
SDL_screen_keyboard_shown = SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
if (SDL_screen_keyboard_shown) {
|
||||||
|
Android_ShowScreenKeyboard(_this, window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern int Android_OnKeyUp(int keycode);
|
||||||
extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
|
extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
|
||||||
extern void Android_ShowScreenKeyboard(_THIS, SDL_Window *window);
|
extern void Android_ShowScreenKeyboard(_THIS, SDL_Window *window);
|
||||||
extern void Android_HideScreenKeyboard(_THIS, SDL_Window *window);
|
extern void Android_HideScreenKeyboard(_THIS, SDL_Window *window);
|
||||||
|
extern void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window);
|
||||||
extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window);
|
extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window);
|
||||||
extern void Android_SetTextInputRect(_THIS, const SDL_Rect *rect);
|
extern void Android_SetTextInputRect(_THIS, const SDL_Rect *rect);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue