diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-05 09:22:01 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-05 09:22:01 +0300 |
commit | 93f7e8712057bc04bd6123a8aa8db0e1e3bdcec8 (patch) | |
tree | 7f50f02633d22f533ee3cbb24d60caaa1d1b19a2 /src/ui | |
parent | fc9a210e8892f9fb982cdf0156d3d06e2f97e1b2 (diff) |
Window: Pinning preference vs. new splits
The pinning direction affects which side links are opened by default.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.c | 24 |
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); |