summaryrefslogtreecommitdiff
path: root/src/ui/root.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/root.c')
-rw-r--r--src/ui/root.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/ui/root.c b/src/ui/root.c
index 375107c9..f91c3ba5 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -420,37 +420,37 @@ static const char *loadAnimationCStr_(void) {
420 return stopSeqCStr_[loadAnimIndex_ % iElemCount(stopSeqCStr_)]; 420 return stopSeqCStr_[loadAnimIndex_ % iElemCount(stopSeqCStr_)];
421} 421}
422 422
423static uint32_t updateReloadAnimation_Window_(uint32_t interval, void *window) { 423static uint32_t updateReloadAnimation_Root_(uint32_t interval, void *root) {
424 iUnused(window);
425 loadAnimIndex_++; 424 loadAnimIndex_++;
426 postCommand_App("window.reload.update"); 425 postCommandf_App("window.reload.update root:%p", root);
427 return interval; 426 return interval;
428} 427}
429 428
430static void setReloadLabel_Window_(iWindow *d, iBool animating) { 429static void setReloadLabel_Root_(iRoot *d, iBool animating) {
431 const iBool isMobile = deviceType_App() != desktop_AppDeviceType; 430 const iBool isMobile = deviceType_App() != desktop_AppDeviceType;
432 iLabelWidget *label = findChild_Widget(d->root.widget, "reload"); 431 iLabelWidget *label = findChild_Widget(d->widget, "reload");
433 updateTextCStr_LabelWidget(label, animating ? loadAnimationCStr_() : 432 updateTextCStr_LabelWidget(
434 (isMobile ? pageMenuCStr_ : reloadCStr_)); 433 label, animating ? loadAnimationCStr_() : (isMobile ? pageMenuCStr_ : reloadCStr_));
435 if (isMobile) { 434 if (isMobile) {
436 setCommand_LabelWidget(label, 435 setCommand_LabelWidget(label,
437 collectNewCStr_String(animating ? "navigate.reload" : "menu.open")); 436 collectNewCStr_String(animating ? "navigate.reload" : "menu.open"));
438 } 437 }
439} 438}
440 439
441static void checkLoadAnimation_Window_(iWindow *d) { 440static void checkLoadAnimation_Root_(iRoot *d) {
442 const iBool isOngoing = isRequestOngoing_DocumentWidget(document_App()); 441 const iBool isOngoing = isRequestOngoing_DocumentWidget(document_Root(d));
443 if (isOngoing && !d->loadAnimTimer) { 442 if (isOngoing && !d->loadAnimTimer) {
444 d->loadAnimTimer = SDL_AddTimer(loadAnimIntervalMs_, updateReloadAnimation_Window_, d); 443 d->loadAnimTimer = SDL_AddTimer(loadAnimIntervalMs_, updateReloadAnimation_Root_, d);
445 } 444 }
446 else if (!isOngoing && d->loadAnimTimer) { 445 else if (!isOngoing && d->loadAnimTimer) {
447 SDL_RemoveTimer(d->loadAnimTimer); 446 SDL_RemoveTimer(d->loadAnimTimer);
448 d->loadAnimTimer = 0; 447 d->loadAnimTimer = 0;
449 } 448 }
450 setReloadLabel_Window_(d, isOngoing); 449 setReloadLabel_Root_(d, isOngoing);
451} 450}
452 451
453void updatePadding_Root(iRoot *d) { 452void updatePadding_Root(iRoot *d) {
453 if (d == NULL) return;
454#if defined (iPlatformAppleMobile) 454#if defined (iPlatformAppleMobile)
455 iWidget *toolBar = findChild_Widget(d->widget, "toolbar"); 455 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
456 float left, top, right, bottom; 456 float left, top, right, bottom;
@@ -470,8 +470,6 @@ void updatePadding_Root(iRoot *d) {
470 are not arranged correctly until it's hidden and reshown. */ 470 are not arranged correctly until it's hidden and reshown. */
471 } 471 }
472 /* Note that `handleNavBarCommands_` also adjusts padding and spacing. */ 472 /* Note that `handleNavBarCommands_` also adjusts padding and spacing. */
473#else
474 iUnused(d);
475#endif 473#endif
476} 474}
477 475
@@ -529,7 +527,7 @@ iBool isNarrow_Root(const iRoot *d) {
529static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { 527static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
530 if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) { 528 if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) {
531 const iBool isPhone = deviceType_App() == phone_AppDeviceType; 529 const iBool isPhone = deviceType_App() == phone_AppDeviceType;
532 const iBool isNarrow = !isPhone && isNarrow_Root(get_Root()); 530 const iBool isNarrow = !isPhone && isNarrow_Root(navBar->root);
533 /* Adjust navbar padding. */ { 531 /* Adjust navbar padding. */ {
534 int hPad = isPhone && isPortrait_App() ? 0 : (isPhone || isNarrow) ? gap_UI / 2 532 int hPad = isPhone && isPortrait_App() ? 0 : (isPhone || isNarrow) ? gap_UI / 2
535 : gap_UI * 3 / 2; 533 : gap_UI * 3 / 2;
@@ -570,7 +568,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
570 updateSize_LabelWidget(btn); 568 updateSize_LabelWidget(btn);
571 } 569 }
572 } 570 }
573 arrange_Widget(get_Window()->root.widget); 571 arrange_Widget(navBar->root->widget);
574 } 572 }
575 /* Resize the URL input field. */ { 573 /* Resize the URL input field. */ {
576 iWidget *urlBar = findChild_Widget(navBar, "url"); 574 iWidget *urlBar = findChild_Widget(navBar, "url");
@@ -582,8 +580,11 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
582 return iFalse; 580 return iFalse;
583 } 581 }
584 else if (equal_Command(cmd, "window.reload.update")) { 582 else if (equal_Command(cmd, "window.reload.update")) {
585 checkLoadAnimation_Window_(get_Window()); 583 if (pointerLabel_Command(cmd, "root") == get_Root()) {
586 return iTrue; 584 checkLoadAnimation_Root_(get_Root());
585 return iTrue;
586 }
587 return iFalse;
587 } 588 }
588 else if (equal_Command(cmd, "navigate.focus")) { 589 else if (equal_Command(cmd, "navigate.focus")) {
589 iWidget *url = findChild_Widget(navBar, "url"); 590 iWidget *url = findChild_Widget(navBar, "url");
@@ -638,7 +639,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
638 visitUrl_Visited(visited_App(), withSpacesEncoded_String(urlStr), 0); /* TODO: internal URI normalization */ 639 visitUrl_Visited(visited_App(), withSpacesEncoded_String(urlStr), 0); /* TODO: internal URI normalization */
639 postCommand_App("visited.changed"); /* sidebar will update */ 640 postCommand_App("visited.changed"); /* sidebar will update */
640 setText_InputWidget(url, urlStr); 641 setText_InputWidget(url, urlStr);
641 checkLoadAnimation_Window_(get_Window()); 642 checkLoadAnimation_Root_(get_Root());
642 dismissPortraitPhoneSidebars_Root(get_Root()); 643 dismissPortraitPhoneSidebars_Root(get_Root());
643 updateNavBarIdentity_(navBar); 644 updateNavBarIdentity_(navBar);
644 updateNavDirButtons_(navBar); 645 updateNavDirButtons_(navBar);
@@ -651,13 +652,13 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
651 return iFalse; 652 return iFalse;
652 } 653 }
653 else if (equal_Command(cmd, "document.request.cancelled")) { 654 else if (equal_Command(cmd, "document.request.cancelled")) {
654 checkLoadAnimation_Window_(get_Window()); 655 checkLoadAnimation_Root_(get_Root());
655 return iFalse; 656 return iFalse;
656 } 657 }
657 else if (equal_Command(cmd, "document.request.started")) { 658 else if (equal_Command(cmd, "document.request.started")) {
658 iInputWidget *url = findChild_Widget(navBar, "url"); 659 iInputWidget *url = findChild_Widget(navBar, "url");
659 setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url")); 660 setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url"));
660 checkLoadAnimation_Window_(get_Window()); 661 checkLoadAnimation_Root_(get_Root());
661 dismissPortraitPhoneSidebars_Root(get_Root()); 662 dismissPortraitPhoneSidebars_Root(get_Root());
662 return iFalse; 663 return iFalse;
663 } 664 }
@@ -668,7 +669,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
668 iDocumentWidget *doc = document_App(); 669 iDocumentWidget *doc = document_App();
669 if (doc) { 670 if (doc) {
670 setText_InputWidget(findChild_Widget(navBar, "url"), url_DocumentWidget(doc)); 671 setText_InputWidget(findChild_Widget(navBar, "url"), url_DocumentWidget(doc));
671 checkLoadAnimation_Window_(get_Window()); 672 checkLoadAnimation_Root_(get_Root());
672 updateNavBarIdentity_(navBar); 673 updateNavBarIdentity_(navBar);
673 } 674 }
674 setFocus_Widget(NULL); 675 setFocus_Widget(NULL);
@@ -722,7 +723,7 @@ static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) {
722 if (pointer_Command(cmd) == findChild_Widget(searchBar, "find.input")) { 723 if (pointer_Command(cmd) == findChild_Widget(searchBar, "find.input")) {
723 if (!isVisible_Widget(searchBar)) { 724 if (!isVisible_Widget(searchBar)) {
724 setFlags_Widget(searchBar, hidden_WidgetFlag | disabled_WidgetFlag, iFalse); 725 setFlags_Widget(searchBar, hidden_WidgetFlag | disabled_WidgetFlag, iFalse);
725 arrange_Widget(get_Window()->root.widget); 726 arrange_Widget(root_Widget(searchBar));
726 postRefresh_App(); 727 postRefresh_App();
727 } 728 }
728 } 729 }
@@ -831,6 +832,9 @@ static int appIconSize_(void) {
831} 832}
832 833
833void updateMetrics_Root(iRoot *d) { 834void updateMetrics_Root(iRoot *d) {
835 if (d == NULL) {
836 return;
837 }
834 /* Custom frame. */ 838 /* Custom frame. */
835 iWidget *winBar = findChild_Widget(d->widget, "winbar"); 839 iWidget *winBar = findChild_Widget(d->widget, "winbar");
836 if (winBar) { 840 if (winBar) {