summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/app.c b/src/app.c
index 2f1e435b..29d8cac4 100644
--- a/src/app.c
+++ b/src/app.c
@@ -406,7 +406,10 @@ static iBool loadState_App_(iApp *d) {
406 readData_File(f, 4, magic); 406 readData_File(f, 4, magic);
407 if (!memcmp(magic, magicTabDocument_App_, 4)) { 407 if (!memcmp(magic, magicTabDocument_App_, 4)) {
408 const int8_t flags = read8_File(f); 408 const int8_t flags = read8_File(f);
409 const int rootIndex = flags & rootIndex1_DocumentStateFlag ? 1 : 0; 409 int rootIndex = flags & rootIndex1_DocumentStateFlag ? 1 : 0;
410 if (rootIndex > numRoots_Window(d->window) - 1) {
411 rootIndex = 0;
412 }
410 setCurrent_Root(d->window->roots[rootIndex]); 413 setCurrent_Root(d->window->roots[rootIndex]);
411 if (isFirstTab[rootIndex]) { 414 if (isFirstTab[rootIndex]) {
412 isFirstTab[rootIndex] = iFalse; 415 isFirstTab[rootIndex] = iFalse;
@@ -1148,9 +1151,12 @@ static int run_App_(iApp *d) {
1148 while (d->isRunning) { 1151 while (d->isRunning) {
1149 dispatchCommands_Periodic(&d->periodic); 1152 dispatchCommands_Periodic(&d->periodic);
1150 processEvents_App(waitForNewEvents_AppEventMode); 1153 processEvents_App(waitForNewEvents_AppEventMode);
1151 setCurrent_Root(NULL);
1152 runTickers_App_(d); 1154 runTickers_App_(d);
1153 refresh_App(); 1155 refresh_App();
1156 /* Change the widget tree while we are not iterating through it. */
1157 if (d->window->splitMode != d->window->pendingSplitMode) {
1158 setSplitMode_Window(d->window, d->window->pendingSplitMode);
1159 }
1154 recycle_Garbage(); 1160 recycle_Garbage();
1155 } 1161 }
1156 SDL_DelEventWatch(resizeWatcher_, d); 1162 SDL_DelEventWatch(resizeWatcher_, d);
@@ -1654,6 +1660,15 @@ iBool handleCommand_App(const char *cmd) {
1654 d->prefs.langTo = argLabel_Command(cmd, "to"); 1660 d->prefs.langTo = argLabel_Command(cmd, "to");
1655 return iTrue; 1661 return iTrue;
1656 } 1662 }
1663 else if (equal_Command(cmd, "ui.frames")) {
1664 d->window->pendingSplitMode =
1665 (argLabel_Command(cmd, "axis") ? vertical_WindowSplit : 0) | (arg_Command(cmd) << 1);
1666 return iTrue;
1667 }
1668// else if (equal_Command(cmd, "window.updatelayout")) {
1669// resize_Window(d->window, -1, -1);
1670// return iTrue;
1671// }
1657 else if (equal_Command(cmd, "window.retain")) { 1672 else if (equal_Command(cmd, "window.retain")) {
1658 d->prefs.retainWindowSize = arg_Command(cmd); 1673 d->prefs.retainWindowSize = arg_Command(cmd);
1659 return iTrue; 1674 return iTrue;
@@ -2009,15 +2024,22 @@ iBool handleCommand_App(const char *cmd) {
2009 arrange_Widget(tabs); 2024 arrange_Widget(tabs);
2010 return iTrue; 2025 return iTrue;
2011 } 2026 }
2012 if (tabCount_Widget(tabs) > 1) { 2027 const iBool isSplit = numRoots_Window(get_Window()) > 1;
2028 if (tabCount_Widget(tabs) > 1 || isSplit) {
2013 iWidget *closed = removeTabPage_Widget(tabs, index); 2029 iWidget *closed = removeTabPage_Widget(tabs, index);
2014 destroy_Widget(closed); /* released later */ 2030 destroy_Widget(closed); /* released later */
2015 if (index == tabCount_Widget(tabs)) { 2031 if (index == tabCount_Widget(tabs)) {
2016 index--; 2032 index--;
2017 } 2033 }
2018 arrange_Widget(tabs); 2034 if (tabCount_Widget(tabs) == 0) {
2019 if (wasCurrent) { 2035 iAssert(isSplit);
2020 postCommandf_App("tabs.switch page:%p", tabPage_Widget(tabs, index)); 2036 postCommand_App("ui.frames arg:0");
2037 }
2038 else {
2039 arrange_Widget(tabs);
2040 if (wasCurrent) {
2041 postCommandf_App("tabs.switch page:%p", tabPage_Widget(tabs, index));
2042 }
2021 } 2043 }
2022 } 2044 }
2023 else { 2045 else {
@@ -2113,7 +2135,7 @@ iBool handleCommand_App(const char *cmd) {
2113 const iPtrArray *homepages = 2135 const iPtrArray *homepages =
2114 list_Bookmarks(d->bookmarks, NULL, filterTagsRegExp_Bookmarks, pattern); 2136 list_Bookmarks(d->bookmarks, NULL, filterTagsRegExp_Bookmarks, pattern);
2115 if (isEmpty_PtrArray(homepages)) { 2137 if (isEmpty_PtrArray(homepages)) {
2116 postCommand_App("open url:about:lagrange"); 2138 postCommand_Root(get_Root(), "open url:about:lagrange");
2117 } 2139 }
2118 else { 2140 else {
2119 iStringSet *urls = iClob(new_StringSet()); 2141 iStringSet *urls = iClob(new_StringSet());
@@ -2125,13 +2147,13 @@ iBool handleCommand_App(const char *cmd) {
2125 } 2147 }
2126 } 2148 }
2127 if (!isEmpty_StringSet(urls)) { 2149 if (!isEmpty_StringSet(urls)) {
2128 postCommandf_App( 2150 postCommandf_Root(get_Root(),
2129 "open url:%s", 2151 "open url:%s",
2130 cstr_String(constAt_StringSet(urls, iRandoms(0, size_StringSet(urls))))); 2152 cstr_String(constAt_StringSet(urls, iRandoms(0, size_StringSet(urls)))));
2131 } 2153 }
2132 } 2154 }
2133 if (argLabel_Command(cmd, "focus")) { 2155 if (argLabel_Command(cmd, "focus")) {
2134 postCommand_App("navigate.focus"); 2156 postCommand_Root(get_Root(), "navigate.focus");
2135 } 2157 }
2136 return iTrue; 2158 return iTrue;
2137 } 2159 }
@@ -2335,6 +2357,7 @@ iObjectList *listDocuments_App(const iRoot *rootOrNull) {
2335 iObjectList *docs = new_ObjectList(); 2357 iObjectList *docs = new_ObjectList();
2336 iForIndices(i, win->roots) { 2358 iForIndices(i, win->roots) {
2337 iRoot *root = win->roots[i]; 2359 iRoot *root = win->roots[i];
2360 if (!root) continue;
2338 if (!rootOrNull || root == rootOrNull) { 2361 if (!rootOrNull || root == rootOrNull) {
2339 const iWidget *tabs = findChild_Widget(root->widget, "doctabs"); 2362 const iWidget *tabs = findChild_Widget(root->widget, "doctabs");
2340 iForEach(ObjectList, i, children_Widget(findChild_Widget(tabs, "tabs.pages"))) { 2363 iForEach(ObjectList, i, children_Widget(findChild_Widget(tabs, "tabs.pages"))) {