summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-18 13:37:23 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-18 13:37:23 +0200
commit480fe2f859b191584113de6e483121d3893eaf3e (patch)
tree84c74f42b348ec8c6d6a81d7cca57e3c939cb6c8 /src/app.c
parentfa174461abdc5c33de16428109c7d46b4f150093 (diff)
Mobile improvements
Seeing if a few forced redraws will take care of the squished view issue. On the phone, showing and hiding the sidebar is not supposed to resize any documents.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index c5ddc454..d5ec7091 100644
--- a/src/app.c
+++ b/src/app.c
@@ -125,6 +125,7 @@ struct Impl_App {
125 iTime lastDropTime; /* for detecting drops of multiple items */ 125 iTime lastDropTime; /* for detecting drops of multiple items */
126 int autoReloadTimer; 126 int autoReloadTimer;
127 iPeriodic periodic; 127 iPeriodic periodic;
128 int warmupFrames; /* forced refresh just after resuming from background */
128 /* Preferences: */ 129 /* Preferences: */
129 iBool commandEcho; /* --echo */ 130 iBool commandEcho; /* --echo */
130 iBool forceSoftwareRender; /* --sw */ 131 iBool forceSoftwareRender; /* --sw */
@@ -587,6 +588,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
587 const iBool isFirstRun = 588 const iBool isFirstRun =
588 !fileExistsCStr_FileInfo(cleanedPath_CStr(concatPath_CStr(dataDir_App_(), "prefs.cfg"))); 589 !fileExistsCStr_FileInfo(cleanedPath_CStr(concatPath_CStr(dataDir_App_(), "prefs.cfg")));
589 d->isFinishedLaunching = iFalse; 590 d->isFinishedLaunching = iFalse;
591 d->warmupFrames = 0;
590 d->launchCommands = new_StringList(); 592 d->launchCommands = new_StringList();
591 iZap(d->lastDropTime); 593 iZap(d->lastDropTime);
592 init_SortedArray(&d->tickers, sizeof(iTicker), cmp_Ticker_); 594 init_SortedArray(&d->tickers, sizeof(iTicker), cmp_Ticker_);
@@ -835,6 +837,9 @@ void trimCache_App(void) {
835} 837}
836 838
837iLocalDef iBool isWaitingAllowed_App_(iApp *d) { 839iLocalDef iBool isWaitingAllowed_App_(iApp *d) {
840 if (d->warmupFrames > 0) {
841 return iFalse;
842 }
838#if defined (LAGRANGE_IDLE_SLEEP) 843#if defined (LAGRANGE_IDLE_SLEEP)
839 if (d->isIdling) { 844 if (d->isIdling) {
840 return iFalse; 845 return iFalse;
@@ -874,6 +879,12 @@ void processEvents_App(enum iAppEventMode eventMode) {
874 clearCache_App_(); 879 clearCache_App_();
875 break; 880 break;
876 case SDL_APP_DIDENTERFOREGROUND: 881 case SDL_APP_DIDENTERFOREGROUND:
882 gotEvents = iTrue;
883 d->warmupFrames = 5;
884#if defined (LAGRANGE_IDLE_SLEEP)
885 d->isIdling = iFalse;
886 d->lastEventTime = SDL_GetTicks();
887#endif
877 postRefresh_App(); 888 postRefresh_App();
878 break; 889 break;
879 case SDL_APP_WILLENTERBACKGROUND: 890 case SDL_APP_WILLENTERBACKGROUND:
@@ -1039,7 +1050,7 @@ static int run_App_(iApp *d) {
1039 d->isRunning = iTrue; 1050 d->isRunning = iTrue;
1040 SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */ 1051 SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */
1041#if defined (iPlatformDesktop) 1052#if defined (iPlatformDesktop)
1042 SDL_AddEventWatch(resizeWatcher_, d); 1053 SDL_AddEventWatch(resizeWatcher_, d); /* redraw window during resizing */
1043#endif 1054#endif
1044 while (d->isRunning) { 1055 while (d->isRunning) {
1045 processEvents_App(waitForNewEvents_AppEventMode); 1056 processEvents_App(waitForNewEvents_AppEventMode);
@@ -1054,11 +1065,17 @@ static int run_App_(iApp *d) {
1054void refresh_App(void) { 1065void refresh_App(void) {
1055 iApp *d = &app_; 1066 iApp *d = &app_;
1056#if defined (LAGRANGE_IDLE_SLEEP) 1067#if defined (LAGRANGE_IDLE_SLEEP)
1057 if (d->isIdling) return; 1068 if (d->warmupFrames == 0 && d->isIdling) {
1069 return;
1070 }
1058#endif 1071#endif
1059 set_Atomic(&d->pendingRefresh, iFalse); 1072 set_Atomic(&d->pendingRefresh, iFalse);
1060 destroyPending_Widget(); 1073 destroyPending_Widget();
1061 draw_Window(d->window); 1074 draw_Window(d->window);
1075 if (d->warmupFrames > 0) {
1076 printf("warmup frame: %d\n", d->warmupFrames);
1077 d->warmupFrames--;
1078 }
1062} 1079}
1063 1080
1064iBool isRefreshPending_App(void) { 1081iBool isRefreshPending_App(void) {