diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-02 09:04:51 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-02 09:04:51 +0300 |
commit | eae0ef64d071e2702fffc1d00f223124f8c6d8b4 (patch) | |
tree | dd57916c55d69427fcf7e629a60edb0e55039221 /src | |
parent | c1fef59fe709a2482444175da3662be26f215138 (diff) |
App: Save split mode; launch event cleanup
The serialized state version was bumped, so old states are incompatible and are ignored.
There were redundant events posted during launch.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 139 | ||||
-rw-r--r-- | src/app.h | 2 | ||||
-rw-r--r-- | src/defs.h | 3 |
3 files changed, 108 insertions, 36 deletions
@@ -124,7 +124,8 @@ struct Impl_App { | |||
124 | int sleepTimer; | 124 | int sleepTimer; |
125 | #endif | 125 | #endif |
126 | iAtomicInt pendingRefresh; | 126 | iAtomicInt pendingRefresh; |
127 | int tabEnum; | 127 | int tabEnum; /* IDs for new tabs */ |
128 | iBool isLoadingPrefs; | ||
128 | iStringList *launchCommands; | 129 | iStringList *launchCommands; |
129 | iBool isFinishedLaunching; | 130 | iBool isFinishedLaunching; |
130 | iTime lastDropTime; /* for detecting drops of multiple items */ | 131 | iTime lastDropTime; /* for detecting drops of multiple items */ |
@@ -306,6 +307,7 @@ static const iString *prefsFileName_(void) { | |||
306 | static void loadPrefs_App_(iApp *d) { | 307 | static void loadPrefs_App_(iApp *d) { |
307 | iUnused(d); | 308 | iUnused(d); |
308 | iBool haveCA = iFalse; | 309 | iBool haveCA = iFalse; |
310 | d->isLoadingPrefs = iTrue; /* affects which notifications get posted */ | ||
309 | /* Create the data dir if it doesn't exist yet. */ | 311 | /* Create the data dir if it doesn't exist yet. */ |
310 | makeDirs_Path(collectNewCStr_String(dataDir_App_())); | 312 | makeDirs_Path(collectNewCStr_String(dataDir_App_())); |
311 | iFile *f = new_File(prefsFileName_()); | 313 | iFile *f = new_File(prefsFileName_()); |
@@ -360,6 +362,7 @@ static void loadPrefs_App_(iApp *d) { | |||
360 | d->prefs.customFrame = iFalse; | 362 | d->prefs.customFrame = iFalse; |
361 | #endif | 363 | #endif |
362 | iRelease(f); | 364 | iRelease(f); |
365 | d->isLoadingPrefs = iFalse; | ||
363 | } | 366 | } |
364 | 367 | ||
365 | static void savePrefs_App_(const iApp *d) { | 368 | static void savePrefs_App_(const iApp *d) { |
@@ -373,6 +376,7 @@ static void savePrefs_App_(const iApp *d) { | |||
373 | } | 376 | } |
374 | 377 | ||
375 | static const char *magicState_App_ = "lgL1"; | 378 | static const char *magicState_App_ = "lgL1"; |
379 | static const char *magicWindow_App_ = "wind"; | ||
376 | static const char *magicTabDocument_App_ = "tabd"; | 380 | static const char *magicTabDocument_App_ = "tabd"; |
377 | 381 | ||
378 | enum iDocumentStateFlag { | 382 | enum iDocumentStateFlag { |
@@ -399,11 +403,20 @@ static iBool loadState_App_(iApp *d) { | |||
399 | return iFalse; | 403 | return iFalse; |
400 | } | 404 | } |
401 | setVersion_Stream(stream_File(f), version); | 405 | setVersion_Stream(stream_File(f), version); |
402 | iDocumentWidget *doc = NULL; // document_App(); /* first one is always from root 0 */ | 406 | /* Window state. */ |
403 | iBool isFirstTab[2] = { iTrue, iTrue }; | 407 | iDocumentWidget *doc = NULL; |
404 | iDocumentWidget *current[2] = { NULL, NULL }; | 408 | iDocumentWidget *current[2] = { NULL, NULL }; |
409 | iBool isFirstTab[2] = { iTrue, iTrue }; | ||
405 | while (!atEnd_File(f)) { | 410 | while (!atEnd_File(f)) { |
406 | readData_File(f, 4, magic); | 411 | readData_File(f, 4, magic); |
412 | if (!memcmp(magic, magicWindow_App_, 4)) { | ||
413 | const int splitMode = read32_File(f); | ||
414 | const int keyRoot = read32_File(f); | ||
415 | d->window->pendingSplitMode = splitMode; | ||
416 | setSplitMode_Window(d->window, splitMode | noEvents_WindowSplit); | ||
417 | d->window->keyRoot = d->window->roots[keyRoot]; | ||
418 | continue; | ||
419 | } | ||
407 | if (!memcmp(magic, magicTabDocument_App_, 4)) { | 420 | if (!memcmp(magic, magicTabDocument_App_, 4)) { |
408 | const int8_t flags = read8_File(f); | 421 | const int8_t flags = read8_File(f); |
409 | int rootIndex = flags & rootIndex1_DocumentStateFlag ? 1 : 0; | 422 | int rootIndex = flags & rootIndex1_DocumentStateFlag ? 1 : 0; |
@@ -431,6 +444,10 @@ static iBool loadState_App_(iApp *d) { | |||
431 | return iFalse; | 444 | return iFalse; |
432 | } | 445 | } |
433 | } | 446 | } |
447 | if (d->window->splitMode) { | ||
448 | /* Update root placement. */ | ||
449 | resize_Window(d->window, -1, -1); | ||
450 | } | ||
434 | iForIndices(i, current) { | 451 | iForIndices(i, current) { |
435 | postCommandf_Root(NULL, "tabs.switch page:%p", current[i]); | 452 | postCommandf_Root(NULL, "tabs.switch page:%p", current[i]); |
436 | } | 453 | } |
@@ -443,16 +460,22 @@ static iBool loadState_App_(iApp *d) { | |||
443 | static void saveState_App_(const iApp *d) { | 460 | static void saveState_App_(const iApp *d) { |
444 | iUnused(d); | 461 | iUnused(d); |
445 | trimCache_App(); | 462 | trimCache_App(); |
463 | iWindow *win = d->window; | ||
446 | iFile *f = newCStr_File(concatPath_CStr(dataDir_App_(), stateFileName_App_)); | 464 | iFile *f = newCStr_File(concatPath_CStr(dataDir_App_(), stateFileName_App_)); |
447 | if (open_File(f, writeOnly_FileMode)) { | 465 | if (open_File(f, writeOnly_FileMode)) { |
448 | writeData_File(f, magicState_App_, 4); | 466 | writeData_File(f, magicState_App_, 4); |
449 | writeU32_File(f, latest_FileVersion); /* version */ | 467 | writeU32_File(f, latest_FileVersion); /* version */ |
468 | /* Begin with window state. */ { | ||
469 | writeData_File(f, magicWindow_App_, 4); | ||
470 | writeU32_File(f, win->splitMode); | ||
471 | writeU32_File(f, win->keyRoot == win->roots[0] ? 0 : 1); | ||
472 | } | ||
450 | iConstForEach(ObjectList, i, iClob(listDocuments_App(NULL))) { | 473 | iConstForEach(ObjectList, i, iClob(listDocuments_App(NULL))) { |
451 | iAssert(isInstance_Object(i.object, &Class_DocumentWidget)); | 474 | iAssert(isInstance_Object(i.object, &Class_DocumentWidget)); |
452 | const iWidget *widget = constAs_Widget(i.object); | 475 | const iWidget *widget = constAs_Widget(i.object); |
453 | writeData_File(f, magicTabDocument_App_, 4); | 476 | writeData_File(f, magicTabDocument_App_, 4); |
454 | int8_t flags = (document_Root(widget->root) == i.object ? current_DocumentStateFlag : 0); | 477 | int8_t flags = (document_Root(widget->root) == i.object ? current_DocumentStateFlag : 0); |
455 | if (widget->root == d->window->roots[1]) { | 478 | if (widget->root == win->roots[1]) { |
456 | flags |= rootIndex1_DocumentStateFlag; | 479 | flags |= rootIndex1_DocumentStateFlag; |
457 | } | 480 | } |
458 | write8_File(f, flags); | 481 | write8_File(f, flags); |
@@ -640,6 +663,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
640 | const iBool isFirstRun = | 663 | const iBool isFirstRun = |
641 | !fileExistsCStr_FileInfo(cleanedPath_CStr(concatPath_CStr(dataDir_App_(), "prefs.cfg"))); | 664 | !fileExistsCStr_FileInfo(cleanedPath_CStr(concatPath_CStr(dataDir_App_(), "prefs.cfg"))); |
642 | d->isFinishedLaunching = iFalse; | 665 | d->isFinishedLaunching = iFalse; |
666 | d->isLoadingPrefs = iFalse; | ||
643 | d->warmupFrames = 0; | 667 | d->warmupFrames = 0; |
644 | d->launchCommands = new_StringList(); | 668 | d->launchCommands = new_StringList(); |
645 | iZap(d->lastDropTime); | 669 | iZap(d->lastDropTime); |
@@ -704,8 +728,8 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
704 | if (!loadState_App_(d)) { | 728 | if (!loadState_App_(d)) { |
705 | postCommand_Root(NULL, "open url:about:help"); | 729 | postCommand_Root(NULL, "open url:about:help"); |
706 | } | 730 | } |
707 | //setThemePalette_Color(d->prefs.theme); | 731 | postCommand_Root(NULL, "~window.unfreeze"); |
708 | postCommand_Root(NULL, "window.unfreeze"); | 732 | postCommand_Root(NULL, "font.reset"); |
709 | d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL); | 733 | d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL); |
710 | postCommand_Root(NULL, "document.autoreload"); | 734 | postCommand_Root(NULL, "document.autoreload"); |
711 | #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) | 735 | #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) |
@@ -1128,7 +1152,6 @@ static int resizeWatcher_(void *user, SDL_Event *event) { | |||
1128 | SDL_Event u = { .type = SDL_USEREVENT }; | 1152 | SDL_Event u = { .type = SDL_USEREVENT }; |
1129 | u.user.code = command_UserEventCode; | 1153 | u.user.code = command_UserEventCode; |
1130 | u.user.data1 = strdup("theme.changed auto:1"); | 1154 | u.user.data1 = strdup("theme.changed auto:1"); |
1131 | /*u.user.windowID = id_Window(d->window);*/ | ||
1132 | dispatchEvent_Window(d->window, &u); | 1155 | dispatchEvent_Window(d->window, &u); |
1133 | } | 1156 | } |
1134 | #endif | 1157 | #endif |
@@ -1255,11 +1278,16 @@ void postRefresh_App(void) { | |||
1255 | if (!wasPending) { | 1278 | if (!wasPending) { |
1256 | SDL_Event ev = { .type = SDL_USEREVENT }; | 1279 | SDL_Event ev = { .type = SDL_USEREVENT }; |
1257 | ev.user.code = refresh_UserEventCode; | 1280 | ev.user.code = refresh_UserEventCode; |
1258 | //ev.user.windowID = id_Window(get_Window()); | ||
1259 | SDL_PushEvent(&ev); | 1281 | SDL_PushEvent(&ev); |
1260 | } | 1282 | } |
1261 | } | 1283 | } |
1262 | 1284 | ||
1285 | void postImmediateRefresh_App(void) { | ||
1286 | SDL_Event ev = { .type = SDL_USEREVENT }; | ||
1287 | ev.user.code = immediateRefresh_UserEventCode; | ||
1288 | SDL_PushEvent(&ev); | ||
1289 | } | ||
1290 | |||
1263 | void postCommand_Root(iRoot *d, const char *command) { | 1291 | void postCommand_Root(iRoot *d, const char *command) { |
1264 | iAssert(command); | 1292 | iAssert(command); |
1265 | if (strlen(command) == 0) { | 1293 | if (strlen(command) == 0) { |
@@ -1284,7 +1312,8 @@ void postCommand_Root(iRoot *d, const char *command) { | |||
1284 | ev.user.data2 = d; /* all events are root-specific */ | 1312 | ev.user.data2 = d; /* all events are root-specific */ |
1285 | SDL_PushEvent(&ev); | 1313 | SDL_PushEvent(&ev); |
1286 | if (app_.commandEcho) { | 1314 | if (app_.commandEcho) { |
1287 | printf("[command] {%d} %s\n", | 1315 | printf("%s[command] {%d} %s\n", |
1316 | app_.isLoadingPrefs ? "[Prefs] " : "", | ||
1288 | (d == NULL ? 0 : d == get_Window()->roots[0] ? 1 : 2), | 1317 | (d == NULL ? 0 : d == get_Window()->roots[0] ? 1 : 2), |
1289 | command); fflush(stdout); | 1318 | command); fflush(stdout); |
1290 | } | 1319 | } |
@@ -1631,6 +1660,7 @@ const iString *searchQueryUrl_App(const iString *queryStringUnescaped) { | |||
1631 | 1660 | ||
1632 | iBool handleCommand_App(const char *cmd) { | 1661 | iBool handleCommand_App(const char *cmd) { |
1633 | iApp *d = &app_; | 1662 | iApp *d = &app_; |
1663 | const iBool isFrozen = !d->window || d->window->isDrawFrozen; | ||
1634 | if (equal_Command(cmd, "config.error")) { | 1664 | if (equal_Command(cmd, "config.error")) { |
1635 | makeSimpleMessage_Widget(uiTextCaution_ColorEscape "CONFIG ERROR", | 1665 | makeSimpleMessage_Widget(uiTextCaution_ColorEscape "CONFIG ERROR", |
1636 | format_CStr("Error in config file: %s\n" | 1666 | format_CStr("Error in config file: %s\n" |
@@ -1693,40 +1723,60 @@ iBool handleCommand_App(const char *cmd) { | |||
1693 | postCommandf_App("window.fullscreen.changed arg:%d", !wasFull); | 1723 | postCommandf_App("window.fullscreen.changed arg:%d", !wasFull); |
1694 | return iTrue; | 1724 | return iTrue; |
1695 | } | 1725 | } |
1726 | else if (equal_Command(cmd, "font.reset")) { | ||
1727 | resetFonts_Text(); | ||
1728 | return iTrue; | ||
1729 | } | ||
1696 | else if (equal_Command(cmd, "font.set")) { | 1730 | else if (equal_Command(cmd, "font.set")) { |
1697 | setFreezeDraw_Window(get_Window(), iTrue); | 1731 | if (!isFrozen) { |
1732 | setFreezeDraw_Window(get_Window(), iTrue); | ||
1733 | } | ||
1698 | d->prefs.font = arg_Command(cmd); | 1734 | d->prefs.font = arg_Command(cmd); |
1699 | setContentFont_Text(d->prefs.font); | 1735 | setContentFont_Text(d->prefs.font); |
1700 | postCommand_App("font.changed"); | 1736 | if (!isFrozen) { |
1701 | postCommand_App("window.unfreeze"); | 1737 | postCommand_App("font.changed"); |
1738 | postCommand_App("window.unfreeze"); | ||
1739 | } | ||
1702 | return iTrue; | 1740 | return iTrue; |
1703 | } | 1741 | } |
1704 | else if (equal_Command(cmd, "headingfont.set")) { | 1742 | else if (equal_Command(cmd, "headingfont.set")) { |
1705 | setFreezeDraw_Window(get_Window(), iTrue); | 1743 | if (!isFrozen) { |
1744 | setFreezeDraw_Window(get_Window(), iTrue); | ||
1745 | } | ||
1706 | d->prefs.headingFont = arg_Command(cmd); | 1746 | d->prefs.headingFont = arg_Command(cmd); |
1707 | setHeadingFont_Text(d->prefs.headingFont); | 1747 | setHeadingFont_Text(d->prefs.headingFont); |
1708 | postCommand_App("font.changed"); | 1748 | if (!isFrozen) { |
1709 | postCommand_App("window.unfreeze"); | 1749 | postCommand_App("font.changed"); |
1750 | postCommand_App("window.unfreeze"); | ||
1751 | } | ||
1710 | return iTrue; | 1752 | return iTrue; |
1711 | } | 1753 | } |
1712 | else if (equal_Command(cmd, "zoom.set")) { | 1754 | else if (equal_Command(cmd, "zoom.set")) { |
1713 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | 1755 | if (!isFrozen) { |
1756 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
1757 | } | ||
1714 | d->prefs.zoomPercent = arg_Command(cmd); | 1758 | d->prefs.zoomPercent = arg_Command(cmd); |
1715 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | 1759 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); |
1716 | postCommand_App("font.changed"); | 1760 | if (!isFrozen) { |
1717 | postCommand_App("window.unfreeze"); | 1761 | postCommand_App("font.changed"); |
1762 | postCommand_App("window.unfreeze"); | ||
1763 | } | ||
1718 | return iTrue; | 1764 | return iTrue; |
1719 | } | 1765 | } |
1720 | else if (equal_Command(cmd, "zoom.delta")) { | 1766 | else if (equal_Command(cmd, "zoom.delta")) { |
1721 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | 1767 | if (!isFrozen) { |
1768 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
1769 | } | ||
1722 | int delta = arg_Command(cmd); | 1770 | int delta = arg_Command(cmd); |
1723 | if (d->prefs.zoomPercent < 100 || (delta < 0 && d->prefs.zoomPercent == 100)) { | 1771 | if (d->prefs.zoomPercent < 100 || (delta < 0 && d->prefs.zoomPercent == 100)) { |
1724 | delta /= 2; | 1772 | delta /= 2; |
1725 | } | 1773 | } |
1726 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); | 1774 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); |
1727 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | 1775 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); |
1728 | postCommand_App("font.changed"); | 1776 | if (!isFrozen) { |
1729 | postCommand_App("window.unfreeze"); | 1777 | postCommand_App("font.changed"); |
1778 | postCommand_App("window.unfreeze"); | ||
1779 | } | ||
1730 | return iTrue; | 1780 | return iTrue; |
1731 | } | 1781 | } |
1732 | else if (equal_Command(cmd, "smoothscroll")) { | 1782 | else if (equal_Command(cmd, "smoothscroll")) { |
@@ -1761,7 +1811,9 @@ iBool handleCommand_App(const char *cmd) { | |||
1761 | else if (equal_Command(cmd, "accent.set")) { | 1811 | else if (equal_Command(cmd, "accent.set")) { |
1762 | d->prefs.accent = arg_Command(cmd); | 1812 | d->prefs.accent = arg_Command(cmd); |
1763 | setThemePalette_Color(d->prefs.theme); | 1813 | setThemePalette_Color(d->prefs.theme); |
1764 | postCommandf_App("theme.changed auto:1"); | 1814 | if (!isFrozen) { |
1815 | invalidate_Window(d->window); | ||
1816 | } | ||
1765 | return iTrue; | 1817 | return iTrue; |
1766 | } | 1818 | } |
1767 | else if (equal_Command(cmd, "ostheme")) { | 1819 | else if (equal_Command(cmd, "ostheme")) { |
@@ -1770,12 +1822,16 @@ iBool handleCommand_App(const char *cmd) { | |||
1770 | } | 1822 | } |
1771 | else if (equal_Command(cmd, "doctheme.dark.set")) { | 1823 | else if (equal_Command(cmd, "doctheme.dark.set")) { |
1772 | d->prefs.docThemeDark = arg_Command(cmd); | 1824 | d->prefs.docThemeDark = arg_Command(cmd); |
1773 | postCommand_App("theme.changed auto:1"); | 1825 | if (!isFrozen) { |
1826 | invalidate_Window(d->window); | ||
1827 | } | ||
1774 | return iTrue; | 1828 | return iTrue; |
1775 | } | 1829 | } |
1776 | else if (equal_Command(cmd, "doctheme.light.set")) { | 1830 | else if (equal_Command(cmd, "doctheme.light.set")) { |
1777 | d->prefs.docThemeLight = arg_Command(cmd); | 1831 | d->prefs.docThemeLight = arg_Command(cmd); |
1778 | postCommand_App("theme.changed auto:1"); | 1832 | if (!isFrozen) { |
1833 | invalidate_Window(d->window); | ||
1834 | } | ||
1779 | return iTrue; | 1835 | return iTrue; |
1780 | } | 1836 | } |
1781 | else if (equal_Command(cmd, "linewidth.set")) { | 1837 | else if (equal_Command(cmd, "linewidth.set")) { |
@@ -1791,16 +1847,20 @@ iBool handleCommand_App(const char *cmd) { | |||
1791 | else if (equal_Command(cmd, "prefs.mono.gemini.changed") || | 1847 | else if (equal_Command(cmd, "prefs.mono.gemini.changed") || |
1792 | equal_Command(cmd, "prefs.mono.gopher.changed")) { | 1848 | equal_Command(cmd, "prefs.mono.gopher.changed")) { |
1793 | const iBool isSet = (arg_Command(cmd) != 0); | 1849 | const iBool isSet = (arg_Command(cmd) != 0); |
1794 | setFreezeDraw_Window(d->window, iTrue); | 1850 | if (!isFrozen) { |
1851 | setFreezeDraw_Window(d->window, iTrue); | ||
1852 | } | ||
1795 | if (startsWith_CStr(cmd, "prefs.mono.gemini")) { | 1853 | if (startsWith_CStr(cmd, "prefs.mono.gemini")) { |
1796 | d->prefs.monospaceGemini = isSet; | 1854 | d->prefs.monospaceGemini = isSet; |
1797 | } | 1855 | } |
1798 | else { | 1856 | else { |
1799 | d->prefs.monospaceGopher = isSet; | 1857 | d->prefs.monospaceGopher = isSet; |
1800 | } | 1858 | } |
1801 | resetFonts_Text(); /* clear the glyph cache */ | 1859 | if (!isFrozen) { |
1802 | postCommand_App("font.changed"); | 1860 | //resetFonts_Text(); /* clear the glyph cache */ |
1803 | postCommand_App("window.unfreeze"); | 1861 | postCommand_App("font.changed"); |
1862 | postCommand_App("window.unfreeze"); | ||
1863 | } | ||
1804 | return iTrue; | 1864 | return iTrue; |
1805 | } | 1865 | } |
1806 | else if (equal_Command(cmd, "prefs.boldlink.dark.changed") || | 1866 | else if (equal_Command(cmd, "prefs.boldlink.dark.changed") || |
@@ -1812,18 +1872,23 @@ iBool handleCommand_App(const char *cmd) { | |||
1812 | else { | 1872 | else { |
1813 | d->prefs.boldLinkLight = isSet; | 1873 | d->prefs.boldLinkLight = isSet; |
1814 | } | 1874 | } |
1815 | resetFonts_Text(); /* clear the glyph cache */ | 1875 | if (!d->isLoadingPrefs) { |
1816 | postCommand_App("font.changed"); | 1876 | postCommand_App("font.changed"); |
1877 | } | ||
1817 | return iTrue; | 1878 | return iTrue; |
1818 | } | 1879 | } |
1819 | else if (equal_Command(cmd, "prefs.biglede.changed")) { | 1880 | else if (equal_Command(cmd, "prefs.biglede.changed")) { |
1820 | d->prefs.bigFirstParagraph = arg_Command(cmd) != 0; | 1881 | d->prefs.bigFirstParagraph = arg_Command(cmd) != 0; |
1821 | postCommand_App("document.layout.changed"); | 1882 | if (!d->isLoadingPrefs) { |
1883 | postCommand_App("document.layout.changed"); | ||
1884 | } | ||
1822 | return iTrue; | 1885 | return iTrue; |
1823 | } | 1886 | } |
1824 | else if (equal_Command(cmd, "prefs.plaintext.wrap.changed")) { | 1887 | else if (equal_Command(cmd, "prefs.plaintext.wrap.changed")) { |
1825 | d->prefs.plainTextWrap = arg_Command(cmd) != 0; | 1888 | d->prefs.plainTextWrap = arg_Command(cmd) != 0; |
1826 | postCommand_App("document.layout.changed"); | 1889 | if (!d->isLoadingPrefs) { |
1890 | postCommand_App("document.layout.changed"); | ||
1891 | } | ||
1827 | return iTrue; | 1892 | return iTrue; |
1828 | } | 1893 | } |
1829 | else if (equal_Command(cmd, "prefs.sideicon.changed")) { | 1894 | else if (equal_Command(cmd, "prefs.sideicon.changed")) { |
@@ -1833,7 +1898,9 @@ iBool handleCommand_App(const char *cmd) { | |||
1833 | } | 1898 | } |
1834 | else if (equal_Command(cmd, "prefs.centershort.changed")) { | 1899 | else if (equal_Command(cmd, "prefs.centershort.changed")) { |
1835 | d->prefs.centerShortDocs = arg_Command(cmd) != 0; | 1900 | d->prefs.centerShortDocs = arg_Command(cmd) != 0; |
1836 | postCommand_App("theme.changed"); | 1901 | if (!isFrozen) { |
1902 | invalidate_Window(d->window); | ||
1903 | } | ||
1837 | return iTrue; | 1904 | return iTrue; |
1838 | } | 1905 | } |
1839 | else if (equal_Command(cmd, "prefs.collapsepreonload.changed")) { | 1906 | else if (equal_Command(cmd, "prefs.collapsepreonload.changed")) { |
@@ -1856,7 +1923,9 @@ iBool handleCommand_App(const char *cmd) { | |||
1856 | } | 1923 | } |
1857 | else if (equal_Command(cmd, "saturation.set")) { | 1924 | else if (equal_Command(cmd, "saturation.set")) { |
1858 | d->prefs.saturation = (float) arg_Command(cmd) / 100.0f; | 1925 | d->prefs.saturation = (float) arg_Command(cmd) / 100.0f; |
1859 | postCommandf_App("theme.changed auto:1"); | 1926 | if (!isFrozen) { |
1927 | invalidate_Window(d->window); | ||
1928 | } | ||
1860 | return iTrue; | 1929 | return iTrue; |
1861 | } | 1930 | } |
1862 | else if (equal_Command(cmd, "cachesize.set")) { | 1931 | else if (equal_Command(cmd, "cachesize.set")) { |
@@ -63,6 +63,7 @@ enum iUserEventCode { | |||
63 | take, it could turn into a tap-and-hold for example. */ | 63 | take, it could turn into a tap-and-hold for example. */ |
64 | widgetTapBegins_UserEventCode = 4, | 64 | widgetTapBegins_UserEventCode = 4, |
65 | widgetTouchEnds_UserEventCode = 5, /* finger lifted, but momentum may continue */ | 65 | widgetTouchEnds_UserEventCode = 5, /* finger lifted, but momentum may continue */ |
66 | immediateRefresh_UserEventCode = 6, /* refresh even though more events are pending */ | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | const iString *execPath_App (void); | 69 | const iString *execPath_App (void); |
@@ -108,6 +109,7 @@ iAny * findWidget_App (const char *id); | |||
108 | void addTicker_App (iTickerFunc ticker, iAny *context); | 109 | void addTicker_App (iTickerFunc ticker, iAny *context); |
109 | void removeTicker_App (iTickerFunc ticker, iAny *context); | 110 | void removeTicker_App (iTickerFunc ticker, iAny *context); |
110 | void postRefresh_App (void); | 111 | void postRefresh_App (void); |
112 | void postImmediateRefresh_App(void); | ||
111 | void postCommand_Root (iRoot *, const char *command); | 113 | void postCommand_Root (iRoot *, const char *command); |
112 | void postCommandf_Root (iRoot *, const char *command, ...); | 114 | void postCommandf_Root (iRoot *, const char *command, ...); |
113 | void postCommandf_App (const char *command, ...); | 115 | void postCommandf_App (const char *command, ...); |
@@ -27,8 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
27 | enum iFileVersion { | 27 | enum iFileVersion { |
28 | initial_FileVersion = 0, | 28 | initial_FileVersion = 0, |
29 | addedResponseTimestamps_FileVersion = 1, | 29 | addedResponseTimestamps_FileVersion = 1, |
30 | multipleRoots_FileVersion = 2, | ||
30 | /* meta */ | 31 | /* meta */ |
31 | latest_FileVersion = 1 | 32 | latest_FileVersion = 2 |
32 | }; | 33 | }; |
33 | 34 | ||
34 | /* Icons */ | 35 | /* Icons */ |