aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <a1ex@dismail.de>2025-04-30 20:22:54 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2025-04-30 20:49:49 +0200
commit19559f536b1e6f4abbfad8e9f29844eaf6544322 (patch)
tree79dd1248399159b1cda7eb2745b635b911f29e10
parente6364911979d9c147a153a4af3352604dd306905 (diff)
Middle-click on back or forward opens in new tab
Reviewed-by: Rodrigo Arias Mallo <rodarima@gmail.com> See: https://lists.mailman3.com/hyperkitty/list/dillo-dev@mailman3.com/thread/XXD2NXCGQLZLJ3V57NCPU3327DAEFKAN/
-rw-r--r--ChangeLog2
-rw-r--r--doc/user_help.in.html3
-rw-r--r--src/nav.c26
-rw-r--r--src/nav.h2
-rw-r--r--src/ui.cc4
-rw-r--r--src/uicmd.cc16
-rw-r--r--src/uicmd.hh2
7 files changed, 54 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ed493a55..e45c8c43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@ dillo-3.3.0 [Unreleased]
- Add about:keys to display current keyboard shortcuts.
- Control + left click opens links in new tab (emulates mouse middle button).
Patches: Rodrigo Arias Mallo
++- Middle click on back or forward button opens page in new tab.
+ Patches: Alex
dillo-3.2.0 [Jan 18, 2025]
diff --git a/doc/user_help.in.html b/doc/user_help.in.html
index b7c9c5a6..9fba7770 100644
--- a/doc/user_help.in.html
+++ b/doc/user_help.in.html
@@ -294,7 +294,8 @@ bar to navigate among history pages.
<p>
When you follow several links across different web pages, they are remembered in
case you can to go back. Use the "Back" and "Forward" buttons of the panel to go
-to the previous or next page.
+to the previous or next page. Click with the left button to open the page in the
+same tab or use the middle button to open it in a new tab.
<p>
You can also right-click on the Back or Forward buttons to open a menu with the
list of previous or next pages available, so you can jump directly to them. Use
diff --git a/src/nav.c b/src/nav.c
index 7b620b66..7814ae22 100644
--- a/src/nav.c
+++ b/src/nav.c
@@ -447,6 +447,19 @@ 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);
+
+ 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)
@@ -461,6 +474,19 @@ void a_Nav_forw(BrowserWindow *bw)
}
/*
+ * Send the browser to next page in the history list in new tab
+ */
+void a_Nav_forw_nt(BrowserWindow *bw)
+{
+ int idx = a_Nav_stack_ptr(bw);
+
+ if (++idx < a_Nav_stack_size(bw)) {
+ a_UIcmd_set_msg(bw, "");
+ a_UIcmd_open_url_nt(bw, a_History_get_url(NAV_UIDX(bw, idx)), +1);
+ }
+}
+
+/*
* Redirect the browser to the HOME page!
*/
void a_Nav_home(BrowserWindow *bw)
diff --git a/src/nav.h b/src/nav.h
index 2bec7e32..e9c03438 100644
--- a/src/nav.h
+++ b/src/nav.h
@@ -18,7 +18,9 @@ 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_forw_nt(BrowserWindow *bw);
void a_Nav_home(BrowserWindow *bw);
void a_Nav_reload(BrowserWindow *bw);
void a_Nav_jump(BrowserWindow *bw, int offset, int new_bw);
diff --git a/src/ui.cc b/src/ui.cc
index 2f05c811..c5870b04 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -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());
@@ -320,6 +322,8 @@ static void b1_cb(Fl_Widget *wid, void *cb_data)
case UI_FORW:
if (b == FL_LEFT_MOUSE) {
a_UIcmd_forw(a_UIcmd_get_bw_by_widget(wid));
+ } else if (b == FL_MIDDLE_MOUSE) {
+ a_UIcmd_forw_nt(a_UIcmd_get_bw_by_widget(wid));
} else if (b == FL_RIGHT_MOUSE) {
a_UIcmd_forw_popup(a_UIcmd_get_bw_by_widget(wid), wid->x(),
wid->y() + wid->h());
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 60381867..15207408 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -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)
@@ -884,6 +892,14 @@ void a_UIcmd_forw(void *vbw)
}
/*
+ * Send the browser to next page in the history list in new tab
+ */
+void a_UIcmd_forw_nt(void *vbw)
+{
+ a_Nav_forw_nt((BrowserWindow*)vbw);
+}
+
+/*
* Popup the navigation menu of the Forward button
*/
void a_UIcmd_forw_popup(void *vbw, int x, int y)
diff --git a/src/uicmd.hh b/src/uicmd.hh
index fe72486a..1343a4a9 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -29,8 +29,10 @@ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url);
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_nt(void *vbw);
void a_UIcmd_forw_popup(void *vbw, int x, int y);
void a_UIcmd_home(void *vbw);
void a_UIcmd_zoom_in(void *vbw);