summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index c4d06d75..a1df2609 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1214,30 +1214,36 @@ void setSplitMode_Window(iWindow *d, int splitFlags) {
1214 /* Add a second root. */ 1214 /* Add a second root. */
1215 iDocumentWidget *moved = document_Root(d->roots[0]); 1215 iDocumentWidget *moved = document_Root(d->roots[0]);
1216 iAssert(d->roots[1] == NULL); 1216 iAssert(d->roots[1] == NULL);
1217 d->roots[1] = new_Root(); 1217 const iBool addToLeft = (prefs_App()->pinSplit == 2);
1218 setCurrent_Root(d->roots[1]); 1218 size_t newRootIndex = 1;
1219 d->keyRoot = d->roots[1]; 1219 if (addToLeft) {
1220 createUserInterface_Root(d->roots[1]); 1220 iSwap(iRoot *, d->roots[0], d->roots[1]);
1221 newRootIndex = 0;
1222 }
1223 d->roots[newRootIndex] = new_Root();
1224 d->keyRoot = d->roots[newRootIndex];
1225 setCurrent_Root(d->roots[newRootIndex]);
1226 createUserInterface_Root(d->roots[newRootIndex]);
1221 if (!isEmpty_String(d->pendingSplitUrl)) { 1227 if (!isEmpty_String(d->pendingSplitUrl)) {
1222 postCommandf_Root(d->roots[1], "open url:%s", 1228 postCommandf_Root(d->roots[newRootIndex], "open url:%s",
1223 cstr_String(d->pendingSplitUrl)); 1229 cstr_String(d->pendingSplitUrl));
1224 clear_String(d->pendingSplitUrl); 1230 clear_String(d->pendingSplitUrl);
1225 } 1231 }
1226 else if (~splitFlags & noEvents_WindowSplit) { 1232 else if (~splitFlags & noEvents_WindowSplit) {
1227 iWidget *docTabs0 = findChild_Widget(d->roots[0]->widget, "doctabs"); 1233 iWidget *docTabs0 = findChild_Widget(d->roots[newRootIndex ^ 1]->widget, "doctabs");
1228 iWidget *docTabs1 = findChild_Widget(d->roots[1]->widget, "doctabs"); 1234 iWidget *docTabs1 = findChild_Widget(d->roots[newRootIndex]->widget, "doctabs");
1229 /* If the old root has multiple tabs, move the current one to the new split. */ 1235 /* If the old root has multiple tabs, move the current one to the new split. */
1230 if (tabCount_Widget(docTabs0) >= 2) { 1236 if (tabCount_Widget(docTabs0) >= 2) {
1231 int movedIndex = tabPageIndex_Widget(docTabs0, moved); 1237 int movedIndex = tabPageIndex_Widget(docTabs0, moved);
1232 removeTabPage_Widget(docTabs0, movedIndex); 1238 removeTabPage_Widget(docTabs0, movedIndex);
1233 showTabPage_Widget(docTabs0, tabPage_Widget(docTabs0, iMax(movedIndex - 1, 0))); 1239 showTabPage_Widget(docTabs0, tabPage_Widget(docTabs0, iMax(movedIndex - 1, 0)));
1234 iRelease(removeTabPage_Widget(docTabs1, 0)); /* delete the default tab */ 1240 iRelease(removeTabPage_Widget(docTabs1, 0)); /* delete the default tab */
1235 setRoot_Widget(as_Widget(moved), d->roots[1]); 1241 setRoot_Widget(as_Widget(moved), d->roots[newRootIndex]);
1236 prependTabPage_Widget(docTabs1, iClob(moved), "", 0, 0); 1242 prependTabPage_Widget(docTabs1, iClob(moved), "", 0, 0);
1237 postCommandf_App("tabs.switch page:%p", moved); 1243 postCommandf_App("tabs.switch page:%p", moved);
1238 } 1244 }
1239 else { 1245 else {
1240 postCommand_Root(d->roots[1], "navigate.home"); 1246 postCommand_Root(d->roots[newRootIndex], "navigate.home");
1241 } 1247 }
1242 } 1248 }
1243 setCurrent_Root(NULL); 1249 setCurrent_Root(NULL);