diff options
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -1306,7 +1306,7 @@ void postCommandf_App(const char *command, ...) { | |||
1306 | 1306 | ||
1307 | void rootOrder_App(iRoot *roots[2]) { | 1307 | void rootOrder_App(iRoot *roots[2]) { |
1308 | const iWindow *win = app_.window; | 1308 | const iWindow *win = app_.window; |
1309 | roots[0] = get_Root(); | 1309 | roots[0] = win->keyRoot; |
1310 | roots[1] = (roots[0] == win->roots[0] ? win->roots[1] : win->roots[0]); | 1310 | roots[1] = (roots[0] == win->roots[0] ? win->roots[1] : win->roots[0]); |
1311 | } | 1311 | } |
1312 | 1312 | ||
@@ -1535,7 +1535,7 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe | |||
1535 | } | 1535 | } |
1536 | arrange_Widget(tabs); | 1536 | arrange_Widget(tabs); |
1537 | refresh_Widget(tabs); | 1537 | refresh_Widget(tabs); |
1538 | postCommandf_App("tab.created id:%s", cstr_String(id_Widget(as_Widget(doc)))); | 1538 | postCommandf_Root(get_Root(), "tab.created id:%s", cstr_String(id_Widget(as_Widget(doc)))); |
1539 | return doc; | 1539 | return doc; |
1540 | } | 1540 | } |
1541 | 1541 | ||
@@ -1906,10 +1906,16 @@ iBool handleCommand_App(const char *cmd) { | |||
1906 | openInDefaultBrowser_App(url); | 1906 | openInDefaultBrowser_App(url); |
1907 | return iTrue; | 1907 | return iTrue; |
1908 | } | 1908 | } |
1909 | iDocumentWidget *doc = document_Command(cmd); | ||
1910 | const int newTab = argLabel_Command(cmd, "newtab"); | 1909 | const int newTab = argLabel_Command(cmd, "newtab"); |
1911 | if (newTab) { | 1910 | iRoot *root = get_Root(); |
1912 | doc = newTab_App(NULL, (newTab & 1) != 0); /* `newtab:2` to open in background */ | 1911 | iRoot *oldRoot = root; |
1912 | if (newTab & otherRoot_OpenTabFlag) { | ||
1913 | root = otherRoot_Window(d->window, root); | ||
1914 | setCurrent_Root(root); /* need to change for widget creation */ | ||
1915 | } | ||
1916 | iDocumentWidget *doc = document_Command(cmd); | ||
1917 | if (newTab & (new_OpenTabFlag | newBackground_OpenTabFlag)) { | ||
1918 | doc = newTab_App(NULL, (newTab & new_OpenTabFlag) != 0); /* `newtab:2` to open in background */ | ||
1913 | } | 1919 | } |
1914 | iHistory *history = history_DocumentWidget(doc); | 1920 | iHistory *history = history_DocumentWidget(doc); |
1915 | const iBool isHistory = argLabel_Command(cmd, "history") != 0; | 1921 | const iBool isHistory = argLabel_Command(cmd, "history") != 0; |
@@ -1936,14 +1942,15 @@ iBool handleCommand_App(const char *cmd) { | |||
1936 | is already available, e.g., it's from "about:" or restored from cache. */ | 1942 | is already available, e.g., it's from "about:" or restored from cache. */ |
1937 | const iRangecc gotoHeading = range_Command(cmd, "gotoheading"); | 1943 | const iRangecc gotoHeading = range_Command(cmd, "gotoheading"); |
1938 | if (gotoHeading.start) { | 1944 | if (gotoHeading.start) { |
1939 | postCommandf_App("document.goto heading:%s", cstr_Rangecc(gotoHeading)); | 1945 | postCommandf_Root(root, "document.goto heading:%s", cstr_Rangecc(gotoHeading)); |
1940 | } | 1946 | } |
1941 | const iRangecc gotoUrlHeading = range_Command(cmd, "gotourlheading"); | 1947 | const iRangecc gotoUrlHeading = range_Command(cmd, "gotourlheading"); |
1942 | if (gotoUrlHeading.start) { | 1948 | if (gotoUrlHeading.start) { |
1943 | postCommandf_App("document.goto heading:%s", | 1949 | postCommandf_Root(root, "document.goto heading:%s", |
1944 | cstrCollect_String(urlDecode_String( | 1950 | cstrCollect_String(urlDecode_String( |
1945 | collect_String(newRange_String(gotoUrlHeading))))); | 1951 | collect_String(newRange_String(gotoUrlHeading))))); |
1946 | } | 1952 | } |
1953 | setCurrent_Root(oldRoot); | ||
1947 | } | 1954 | } |
1948 | else if (equal_Command(cmd, "document.request.cancelled")) { | 1955 | else if (equal_Command(cmd, "document.request.cancelled")) { |
1949 | /* TODO: How should cancelled requests be treated in the history? */ | 1956 | /* TODO: How should cancelled requests be treated in the history? */ |
@@ -2016,6 +2023,12 @@ iBool handleCommand_App(const char *cmd) { | |||
2016 | } | 2023 | } |
2017 | return iTrue; | 2024 | return iTrue; |
2018 | } | 2025 | } |
2026 | else if (equal_Command(cmd, "keyroot.next")) { | ||
2027 | if (setKeyRoot_Window(d->window, otherRoot_Window(d->window, d->window->keyRoot))) { | ||
2028 | setFocus_Widget(NULL); | ||
2029 | } | ||
2030 | return iTrue; | ||
2031 | } | ||
2019 | else if (equal_Command(cmd, "quit")) { | 2032 | else if (equal_Command(cmd, "quit")) { |
2020 | SDL_Event ev; | 2033 | SDL_Event ev; |
2021 | ev.type = SDL_QUIT; | 2034 | ev.type = SDL_QUIT; |