summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-07 14:06:21 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-07 14:06:21 +0200
commitab2e2598cf32348f4bc2d56059c07f404d1e61b7 (patch)
treeb8714975d2e9ff99d83e7b31c29d0d556a724387 /src/app.c
parentcd8950953ad6c4361fbc140007ce9cc04fef1e6c (diff)
parent88baf053cd0e282366a618d9de955ab77063ce10 (diff)
Merge branch 'dev' of skyjake.fi:skyjake/lagrange into dev
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/app.c b/src/app.c
index b233b12d..db997817 100644
--- a/src/app.c
+++ b/src/app.c
@@ -291,6 +291,11 @@ static void loadPrefs_App_(iApp *d) {
291 if (equal_Command(cmd, "uiscale")) { 291 if (equal_Command(cmd, "uiscale")) {
292 setUiScale_Window(get_Window(), argf_Command(cmd)); 292 setUiScale_Window(get_Window(), argf_Command(cmd));
293 } 293 }
294 else if (equal_Command(cmd, "ca.file") || equal_Command(cmd, "ca.path")) {
295 /* Background requests may be started before these commands would get
296 handled via the event loop. */
297 handleCommand_App(cmd);
298 }
294 else if (equal_Command(cmd, "customframe")) { 299 else if (equal_Command(cmd, "customframe")) {
295 d->prefs.customFrame = arg_Command(cmd); 300 d->prefs.customFrame = arg_Command(cmd);
296 } 301 }
@@ -604,11 +609,6 @@ static void init_App_(iApp *d, int argc, char **argv) {
604 d->bookmarks = new_Bookmarks(); 609 d->bookmarks = new_Bookmarks();
605 d->tabEnum = 0; /* generates unique IDs for tab pages */ 610 d->tabEnum = 0; /* generates unique IDs for tab pages */
606 setThemePalette_Color(d->prefs.theme); 611 setThemePalette_Color(d->prefs.theme);
607#if defined (LAGRANGE_IDLE_SLEEP)
608 d->isIdling = iFalse;
609 d->lastEventTime = 0;
610 d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d);
611#endif
612#if defined (iPlatformAppleDesktop) 612#if defined (iPlatformAppleDesktop)
613 setupApplication_MacOS(); 613 setupApplication_MacOS();
614#endif 614#endif
@@ -618,6 +618,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
618 init_Keys(); 618 init_Keys();
619 loadPrefs_App_(d); 619 loadPrefs_App_(d);
620 load_Keys(dataDir_App_()); 620 load_Keys(dataDir_App_());
621 d->window = new_Window(d->initialWindowRect);
621 load_Visited(d->visited, dataDir_App_()); 622 load_Visited(d->visited, dataDir_App_());
622 load_Bookmarks(d->bookmarks, dataDir_App_()); 623 load_Bookmarks(d->bookmarks, dataDir_App_());
623 load_MimeHooks(d->mimehooks, dataDir_App_()); 624 load_MimeHooks(d->mimehooks, dataDir_App_());
@@ -633,9 +634,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
633 collectNewCStr_String("Getting Started"), 634 collectNewCStr_String("Getting Started"),
634 collectNewCStr_String("remotesource"), 635 collectNewCStr_String("remotesource"),
635 0x1f306); 636 0x1f306);
636 fetchRemote_Bookmarks(d->bookmarks);
637 } 637 }
638 d->window = new_Window(d->initialWindowRect);
639 init_Feeds(dataDir_App_()); 638 init_Feeds(dataDir_App_());
640 /* Widget state init. */ 639 /* Widget state init. */
641 processEvents_App(postedEventsOnly_AppEventMode); 640 processEvents_App(postedEventsOnly_AppEventMode);
@@ -645,6 +644,11 @@ static void init_App_(iApp *d, int argc, char **argv) {
645 postCommand_App("window.unfreeze"); 644 postCommand_App("window.unfreeze");
646 d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL); 645 d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL);
647 postCommand_App("document.autoreload"); 646 postCommand_App("document.autoreload");
647#if defined (LAGRANGE_IDLE_SLEEP)
648 d->isIdling = iFalse;
649 d->lastEventTime = 0;
650 d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d);
651#endif
648 d->isFinishedLaunching = iTrue; 652 d->isFinishedLaunching = iTrue;
649 /* Run any commands that were pending completion of launch. */ { 653 /* Run any commands that were pending completion of launch. */ {
650 iForEach(StringList, i, d->launchCommands) { 654 iForEach(StringList, i, d->launchCommands) {
@@ -657,6 +661,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
657 } 661 }
658 iRelease(openCmds); 662 iRelease(openCmds);
659 } 663 }
664 fetchRemote_Bookmarks(d->bookmarks);
660} 665}
661 666
662static void deinit_App(iApp *d) { 667static void deinit_App(iApp *d) {
@@ -1004,7 +1009,7 @@ static int resizeWatcher_(void *user, SDL_Event *event) {
1004 SDL_Event u = { .type = SDL_USEREVENT }; 1009 SDL_Event u = { .type = SDL_USEREVENT };
1005 u.user.code = command_UserEventCode; 1010 u.user.code = command_UserEventCode;
1006 u.user.data1 = strdup("theme.changed"); 1011 u.user.data1 = strdup("theme.changed");
1007 u.user.windowID = id_Window(d->window); 1012 /*u.user.windowID = id_Window(d->window);*/
1008 dispatchEvent_Widget(d->window->root, &u); 1013 dispatchEvent_Widget(d->window->root, &u);
1009 } 1014 }
1010#endif 1015#endif
@@ -1095,12 +1100,9 @@ void postRefresh_App(void) {
1095#endif 1100#endif
1096 const iBool wasPending = exchange_Atomic(&d->pendingRefresh, iTrue); 1101 const iBool wasPending = exchange_Atomic(&d->pendingRefresh, iTrue);
1097 if (!wasPending) { 1102 if (!wasPending) {
1098 SDL_Event ev; 1103 SDL_Event ev = { .type = SDL_USEREVENT };
1099 ev.user.type = SDL_USEREVENT; 1104 ev.user.code = refresh_UserEventCode;
1100 ev.user.code = refresh_UserEventCode; 1105 //ev.user.windowID = id_Window(get_Window());
1101 ev.user.windowID = id_Window(get_Window());
1102 ev.user.data1 = NULL;
1103 ev.user.data2 = NULL;
1104 SDL_PushEvent(&ev); 1106 SDL_PushEvent(&ev);
1105 } 1107 }
1106} 1108}
@@ -1111,7 +1113,6 @@ void postCommand_App(const char *command) {
1111 if (strlen(command) == 0) { 1113 if (strlen(command) == 0) {
1112 return; 1114 return;
1113 } 1115 }
1114 SDL_Event ev;
1115 if (*command == '!') { 1116 if (*command == '!') {
1116 /* Global command; this is global context so just ignore. */ 1117 /* Global command; this is global context so just ignore. */
1117 command++; 1118 command++;
@@ -1124,11 +1125,10 @@ void postCommand_App(const char *command) {
1124 return; 1125 return;
1125 } 1126 }
1126 } 1127 }
1127 ev.user.type = SDL_USEREVENT; 1128 SDL_Event ev = { .type = SDL_USEREVENT };
1128 ev.user.code = command_UserEventCode; 1129 ev.user.code = command_UserEventCode;
1129 ev.user.windowID = id_Window(get_Window()); 1130 /*ev.user.windowID = id_Window(get_Window());*/
1130 ev.user.data1 = strdup(command); 1131 ev.user.data1 = strdup(command);
1131 ev.user.data2 = NULL;
1132 SDL_PushEvent(&ev); 1132 SDL_PushEvent(&ev);
1133 if (app_.commandEcho) { 1133 if (app_.commandEcho) {
1134 printf("[command] %s\n", command); fflush(stdout); 1134 printf("[command] %s\n", command); fflush(stdout);