From eddc86b7b0795fe7c7a82d86f6ee151ccdca229f Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 6 Mar 2021 14:44:17 +0200 Subject: Mobile: Dealing with keyboard height The software keyboard obstructs part of the UI, so need to offset the view if the focused input widget would not be visible. --- src/app.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/app.c') diff --git a/src/app.c b/src/app.c index a7539203..ada142f0 100644 --- a/src/app.c +++ b/src/app.c @@ -819,6 +819,11 @@ iLocalDef iBool isWaitingAllowed_App_(iApp *d) { if (d->isIdling) { return iFalse; } +#endif +#if defined (iPlatformMobile) + if (!isFinished_Anim(&d->window->rootOffset)) { + return iFalse; + } #endif return !value_Atomic(&d->pendingRefresh) && isEmpty_SortedArray(&d->tickers); } @@ -929,7 +934,7 @@ void processEvents_App(enum iAppEventMode eventMode) { } } #if defined (LAGRANGE_IDLE_SLEEP) - if (d->isIdling && !gotEvents) { + if (d->isIdling && !gotEvents && isFinished_Anim(&d->window->rootOffset)) { /* This is where we spend most of our time when idle. 60 Hz still quite a lot but we can't wait too long after the user tries to interact again with the app. In any case, on macOS SDL_WaitEvent() seems to use 10x more CPU time than sleeping. */ @@ -1135,8 +1140,7 @@ iMimeHooks *mimeHooks_App(void) { } iBool isLandscape_App(void) { - const iApp *d = &app_; - const iInt2 size = rootSize_Window(d->window); + const iInt2 size = rootSize_Window(get_Window()); return size.x > size.y; } @@ -1700,6 +1704,7 @@ iBool handleCommand_App(const char *cmd) { #if defined (iPlatformAppleMobile) /* Can't close the last on mobile. */ if (tabCount_Widget(tabs) == 1) { + postCommand_App("navigate.home"); return iTrue; } #endif -- cgit v1.2.3