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);
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);
_______________________________________________
Dillo-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]