[PATCH] Middle-click on back button to open prev. page in new tab

Hi list, Hope you are all doing well! I have a small feature idea: Sometimes I want to go back to the previous page, but also keep the current page open. Obviously I can go back and then open the last page in a new tab, but that can be annoying having to find and click on the link again. One solution is to make middle-clicking on the back button open the previous page in a new tab. Attached is a working proof-of-concept patch. Any feedback would be welcome! Regards, Alex diff -upr a/src/nav.c b/src/nav.c --- a/src/nav.c Mon Apr 21 21:42:32 2025 +++ b/src/nav.c Sun Apr 27 10:11:36 2025 @@ -447,6 +447,20 @@ void a_Nav_back(BrowserWindow *bw) } /* + * Send the browser back to previous page in new tab + */ +void a_Nav_back_nt(BrowserWindow *bw) +{ + int idx = a_Nav_stack_ptr(bw); + + a_Nav_cancel_expect(bw); + if (--idx >= 0){ + a_UIcmd_set_msg(bw, ""); + a_UIcmd_open_url_nt(bw, a_History_get_url(NAV_UIDX(bw,idx)), -1); + } +} + +/* * Send the browser to next page in the history list */ void a_Nav_forw(BrowserWindow *bw) diff -upr a/src/nav.h b/src/nav.h --- a/src/nav.h Mon Apr 21 21:42:32 2025 +++ b/src/nav.h Sun Apr 27 10:12:00 2025 @@ -18,6 +18,7 @@ void a_Nav_push(BrowserWindow *bw, const DilloUrl *url const DilloUrl *requester); void a_Nav_repush(BrowserWindow *bw); void a_Nav_back(BrowserWindow *bw); +void a_Nav_back_nt(BrowserWindow *bw); void a_Nav_forw(BrowserWindow *bw); void a_Nav_home(BrowserWindow *bw); void a_Nav_reload(BrowserWindow *bw); diff -upr a/src/ui.cc b/src/ui.cc --- a/src/ui.cc Mon Apr 21 21:42:32 2025 +++ b/src/ui.cc Sun Apr 27 10:13:45 2025 @@ -312,6 +312,8 @@ static void b1_cb(Fl_Widget *wid, void *cb_data) case UI_BACK: if (b == FL_LEFT_MOUSE) { a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid)); + } else if (b == FL_MIDDLE_MOUSE) { + a_UIcmd_back_nt(a_UIcmd_get_bw_by_widget(wid)); } else if (b == FL_RIGHT_MOUSE) { a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid), wid->x(), wid->y() + wid->h()); diff -upr a/src/uicmd.cc b/src/uicmd.cc --- a/src/uicmd.cc Mon Apr 21 21:42:32 2025 +++ b/src/uicmd.cc Sun Apr 27 10:12:30 2025 @@ -868,6 +868,14 @@ void a_UIcmd_back(void *vbw) } /* + * Send the browser back to previous page in a new tab + */ +void a_UIcmd_back_nt(void *vbw) +{ + a_Nav_back_nt((BrowserWindow*)vbw); +} + +/* * Popup the navigation menu of the Back button */ void a_UIcmd_back_popup(void *vbw, int x, int y) diff -upr a/src/uicmd.hh b/src/uicmd.hh --- a/src/uicmd.hh Mon Apr 21 21:42:32 2025 +++ b/src/uicmd.hh Sun Apr 27 10:12:51 2025 @@ -29,6 +29,7 @@ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUr void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url); void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus); void a_UIcmd_back(void *vbw); +void a_UIcmd_back_nt(void *vbw); void a_UIcmd_back_popup(void *vbw, int x, int y); void a_UIcmd_forw(void *vbw); void a_UIcmd_forw_popup(void *vbw, int x, int y);

Hi Alex, On Sun, Apr 27, 2025 at 10:23:37AM +0200, a1ex@dismail.de wrote:
Hi list,
Hope you are all doing well!
I have a small feature idea:
Sometimes I want to go back to the previous page, but also keep the current page open.
Obviously I can go back and then open the last page in a new tab, but that can be annoying having to find and click on the link again.
Keep in mind that you can right-click the back or forward buttons to open a list of pages, and middle click any to open them in new tabs. Not sure if this already fits your needs: https://dillo-browser.github.io/user_help.html#history Best, Rodrigo.

Hi Rodrigo, Rodrigo Arias <rodarima@gmail.com> wrote:
Keep in mind that you can right-click the back or forward buttons to open a list of pages, and middle click any to open them in new tabs. Not sure if this already fits your needs:
Lol, this is true! I seem to have a real knack for "fixing" non-existent problems :) But, I think it's still useful to have, since now the action can be performed with just 1 click, instead of 2. Also browsers like Firefox offer the middle-click back feature like this, so it might be more intuitive for some users. Regards, Alex

Hi,
But, I think it's still useful to have, since now the action can be performed with just 1 click, instead of 2. Also browsers like Firefox offer the middle-click back feature like this, so it might be more intuitive for some users.
I think it makes sense for Dillo to behave in that way as well. However, the current patch needs some changes. See below:
diff -upr a/src/nav.c b/src/nav.c --- a/src/nav.c Mon Apr 21 21:42:32 2025 +++ b/src/nav.c Sun Apr 27 10:11:36 2025 @@ -447,6 +447,20 @@ void a_Nav_back(BrowserWindow *bw) }
/* + * Send the browser back to previous page in new tab + */ +void a_Nav_back_nt(BrowserWindow *bw) +{ + int idx = a_Nav_stack_ptr(bw); + + a_Nav_cancel_expect(bw);
I think you don't want to a_Nav_cancel_expect(), as this will make the current tab stop loading.
+ if (--idx >= 0){ + a_UIcmd_set_msg(bw, ""); + a_UIcmd_open_url_nt(bw, a_History_get_url(NAV_UIDX(bw,idx)), -1); ^add space
The problem with this approach is that the newly opened tab lacks the history of the previous tab. The same problem happens with the current mechanism by opening the history menu and middle clicking an item, but it would be nice to keep it if not too hard. This new behavior needs to be added to doc/user_help.in.html as well, as otherwise it will be hard to guess.
+ } +} + +/* * Send the browser to next page in the history list */ void a_Nav_forw(BrowserWindow *bw) diff -upr a/src/nav.h b/src/nav.h --- a/src/nav.h Mon Apr 21 21:42:32 2025 +++ b/src/nav.h Sun Apr 27 10:12:00 2025 @@ -18,6 +18,7 @@ void a_Nav_push(BrowserWindow *bw, const DilloUrl *url const DilloUrl *requester); void a_Nav_repush(BrowserWindow *bw); void a_Nav_back(BrowserWindow *bw); +void a_Nav_back_nt(BrowserWindow *bw); void a_Nav_forw(BrowserWindow *bw);
We probably should add another one for the forward button too, right?
void a_Nav_home(BrowserWindow *bw); void a_Nav_reload(BrowserWindow *bw); diff -upr a/src/ui.cc b/src/ui.cc --- a/src/ui.cc Mon Apr 21 21:42:32 2025 +++ b/src/ui.cc Sun Apr 27 10:13:45 2025 @@ -312,6 +312,8 @@ static void b1_cb(Fl_Widget *wid, void *cb_data) case UI_BACK: if (b == FL_LEFT_MOUSE) { a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid)); + } else if (b == FL_MIDDLE_MOUSE) { + a_UIcmd_back_nt(a_UIcmd_get_bw_by_widget(wid)); } else if (b == FL_RIGHT_MOUSE) { a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid), wid->x(), wid->y() + wid->h()); diff -upr a/src/uicmd.cc b/src/uicmd.cc --- a/src/uicmd.cc Mon Apr 21 21:42:32 2025 +++ b/src/uicmd.cc Sun Apr 27 10:12:30 2025 @@ -868,6 +868,14 @@ void a_UIcmd_back(void *vbw) }
/* + * Send the browser back to previous page in a new tab + */ +void a_UIcmd_back_nt(void *vbw) +{ + a_Nav_back_nt((BrowserWindow*)vbw); +} + +/* * Popup the navigation menu of the Back button */ void a_UIcmd_back_popup(void *vbw, int x, int y) diff -upr a/src/uicmd.hh b/src/uicmd.hh --- a/src/uicmd.hh Mon Apr 21 21:42:32 2025 +++ b/src/uicmd.hh Sun Apr 27 10:12:51 2025 @@ -29,6 +29,7 @@ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUr void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url); void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus); void a_UIcmd_back(void *vbw); +void a_UIcmd_back_nt(void *vbw); void a_UIcmd_back_popup(void *vbw, int x, int y); void a_UIcmd_forw(void *vbw); void a_UIcmd_forw_popup(void *vbw, int x, int y);
participants (2)
-
a1ex@dismail.de
-
Rodrigo Arias