summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.c41
-rw-r--r--src/ui/documentwidget.c4
2 files changed, 27 insertions, 18 deletions
diff --git a/src/app.c b/src/app.c
index ebb61c86..b6a73c55 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1155,13 +1155,13 @@ static iBool nextEvent_App_(iApp *d, enum iAppEventMode eventMode, SDL_Event *ev
1155 return SDL_PollEvent(event); 1155 return SDL_PollEvent(event);
1156} 1156}
1157 1157
1158static const iPtrArray *listWindows_App_(const iApp *d) { 1158static iPtrArray *listWindows_App_(const iApp *d, iPtrArray *windows) {
1159 iPtrArray *list = collectNew_PtrArray(); 1159 clear_PtrArray(windows);
1160 iReverseConstForEach(PtrArray, i, &d->popupWindows) { 1160 iReverseConstForEach(PtrArray, i, &d->popupWindows) {
1161 pushBack_PtrArray(list, i.ptr); 1161 pushBack_PtrArray(windows, i.ptr);
1162 } 1162 }
1163 pushBack_PtrArray(list, d->window); 1163 pushBack_PtrArray(windows, d->window);
1164 return list; 1164 return windows;
1165} 1165}
1166 1166
1167void processEvents_App(enum iAppEventMode eventMode) { 1167void processEvents_App(enum iAppEventMode eventMode) {
@@ -1169,6 +1169,8 @@ void processEvents_App(enum iAppEventMode eventMode) {
1169 iRoot *oldCurrentRoot = current_Root(); /* restored afterwards */ 1169 iRoot *oldCurrentRoot = current_Root(); /* restored afterwards */
1170 SDL_Event ev; 1170 SDL_Event ev;
1171 iBool gotEvents = iFalse; 1171 iBool gotEvents = iFalse;
1172 iPtrArray windows;
1173 init_PtrArray(&windows);
1172 while (nextEvent_App_(d, eventMode, &ev)) { 1174 while (nextEvent_App_(d, eventMode, &ev)) {
1173#if defined (iPlatformAppleMobile) 1175#if defined (iPlatformAppleMobile)
1174 if (processEvent_iOS(&ev)) { 1176 if (processEvent_iOS(&ev)) {
@@ -1331,7 +1333,8 @@ void processEvents_App(enum iAppEventMode eventMode) {
1331#endif 1333#endif
1332 /* Per-window processing. */ 1334 /* Per-window processing. */
1333 iBool wasUsed = iFalse; 1335 iBool wasUsed = iFalse;
1334 iConstForEach(PtrArray, iter, listWindows_App_(d)) { 1336 listWindows_App_(d, &windows);
1337 iConstForEach(PtrArray, iter, &windows) {
1335 iWindow *window = iter.ptr; 1338 iWindow *window = iter.ptr;
1336 setCurrent_Window(window); 1339 setCurrent_Window(window);
1337 window->lastHover = window->hover; 1340 window->lastHover = window->hover;
@@ -1364,7 +1367,8 @@ void processEvents_App(enum iAppEventMode eventMode) {
1364 handleCommand_Win32(command_UserEvent(&ev)); 1367 handleCommand_Win32(command_UserEvent(&ev));
1365#endif 1368#endif
1366 if (isMetricsChange_UserEvent(&ev)) { 1369 if (isMetricsChange_UserEvent(&ev)) {
1367 iConstForEach(PtrArray, iter, listWindows_App_(d)) { 1370 listWindows_App_(d, &windows);
1371 iConstForEach(PtrArray, iter, &windows) {
1368 iWindow *window = iter.ptr; 1372 iWindow *window = iter.ptr;
1369 iForIndices(i, window->roots) { 1373 iForIndices(i, window->roots) {
1370 iRoot *root = window->roots[i]; 1374 iRoot *root = window->roots[i];
@@ -1383,7 +1387,8 @@ void processEvents_App(enum iAppEventMode eventMode) {
1383 free(ev.user.data1); 1387 free(ev.user.data1);
1384 } 1388 }
1385 /* Refresh after hover changes. */ { 1389 /* Refresh after hover changes. */ {
1386 iConstForEach(PtrArray, iter, listWindows_App_(d)) { 1390 listWindows_App_(d, &windows);
1391 iConstForEach(PtrArray, iter, &windows) {
1387 iWindow *window = iter.ptr; 1392 iWindow *window = iter.ptr;
1388 if (window->lastHover != window->hover) { 1393 if (window->lastHover != window->hover) {
1389 refresh_Widget(window->lastHover); 1394 refresh_Widget(window->lastHover);
@@ -1395,6 +1400,7 @@ void processEvents_App(enum iAppEventMode eventMode) {
1395 } 1400 }
1396 } 1401 }
1397 } 1402 }
1403 deinit_PtrArray(&windows);
1398#if defined (LAGRANGE_ENABLE_IDLE_SLEEP) 1404#if defined (LAGRANGE_ENABLE_IDLE_SLEEP)
1399 if (d->isIdling && !gotEvents) { 1405 if (d->isIdling && !gotEvents) {
1400 /* This is where we spend most of our time when idle. 60 Hz still quite a lot but we 1406 /* This is where we spend most of our time when idle. 60 Hz still quite a lot but we
@@ -1482,9 +1488,11 @@ void refresh_App(void) {
1482 return; 1488 return;
1483 } 1489 }
1484#endif 1490#endif
1485 const iPtrArray *windows = listWindows_App_(d); 1491 iPtrArray windows;
1492 init_PtrArray(&windows);
1493 listWindows_App_(d, &windows);
1486 /* Destroy pending widgets. */ { 1494 /* Destroy pending widgets. */ {
1487 iConstForEach(PtrArray, j, windows) { 1495 iConstForEach(PtrArray, j, &windows) {
1488 iWindow *win = j.ptr; 1496 iWindow *win = j.ptr;
1489 setCurrent_Window(win); 1497 setCurrent_Window(win);
1490 iForIndices(i, win->roots) { 1498 iForIndices(i, win->roots) {
@@ -1495,12 +1503,10 @@ void refresh_App(void) {
1495 } 1503 }
1496 } 1504 }
1497 } 1505 }
1498 /* TODO: Pending refresh is window-specific. */ 1506 /* TODO: `pendingRefresh` should be window-specific. */
1499 if (!exchange_Atomic(&d->pendingRefresh, iFalse)) { 1507 if (exchange_Atomic(&d->pendingRefresh, iFalse)) {
1500 return; 1508 /* Draw each window. */
1501 } 1509 iConstForEach(PtrArray, j, &windows) {
1502 /* Draw each window. */ {
1503 iConstForEach(PtrArray, j, windows) {
1504 iWindow *win = j.ptr; 1510 iWindow *win = j.ptr;
1505 setCurrent_Window(win); 1511 setCurrent_Window(win);
1506 switch (win->type) { 1512 switch (win->type) {
@@ -1520,6 +1526,7 @@ void refresh_App(void) {
1520 if (d->warmupFrames > 0) { 1526 if (d->warmupFrames > 0) {
1521 d->warmupFrames--; 1527 d->warmupFrames--;
1522 } 1528 }
1529 deinit_PtrArray(&windows);
1523} 1530}
1524 1531
1525iBool isRefreshPending_App(void) { 1532iBool isRefreshPending_App(void) {
@@ -2096,7 +2103,7 @@ const iString *searchQueryUrl_App(const iString *queryStringUnescaped) {
2096 2103
2097void resetFonts_App(void) { 2104void resetFonts_App(void) {
2098 iApp *d = &app_; 2105 iApp *d = &app_;
2099 iConstForEach(PtrArray, win, listWindows_App_(d)) { 2106 iConstForEach(PtrArray, win, listWindows_App_(d, collectNew_PtrArray())) {
2100 resetFonts_Text(text_Window(win.ptr)); 2107 resetFonts_Text(text_Window(win.ptr));
2101 } 2108 }
2102} 2109}
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index b6f3b5ce..4c194608 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -4584,7 +4584,9 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4584 appendCStr_String(&str, " \u2014 "); 4584 appendCStr_String(&str, " \u2014 ");
4585 appendCStr_String( 4585 appendCStr_String(
4586 &str, escape_Color(linkColor_GmDocument(doc, run->linkId, visited_GmLinkPart))); 4586 &str, escape_Color(linkColor_GmDocument(doc, run->linkId, visited_GmLinkPart)));
4587 append_String(&str, collect_String(format_Date(&date, "%b %d"))); 4587 iString *dateStr = format_Date(&date, "%b %d");
4588 append_String(&str, dateStr);
4589 delete_String(dateStr);
4588 } 4590 }
4589 if (!isEmpty_String(&str)) { 4591 if (!isEmpty_String(&str)) {
4590 if (run->isRTL) { 4592 if (run->isRTL) {