From 19559f536b1e6f4abbfad8e9f29844eaf6544322 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Apr 2025 20:22:54 +0200 Subject: Middle-click on back or forward opens in new tab Reviewed-by: Rodrigo Arias Mallo See: https://lists.mailman3.com/hyperkitty/list/dillo-dev@mailman3.com/thread/XXD2NXCGQLZLJ3V57NCPU3327DAEFKAN/ --- src/nav.c | 26 ++++++++++++++++++++++++++ src/nav.h | 2 ++ src/ui.cc | 4 ++++ src/uicmd.cc | 16 ++++++++++++++++ src/uicmd.hh | 2 ++ 5 files changed, 50 insertions(+) (limited to 'src') diff --git a/src/nav.c b/src/nav.c index 7b620b66..7814ae22 100644 --- a/src/nav.c +++ b/src/nav.c @@ -446,6 +446,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 */ @@ -460,6 +473,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! */ 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 @@ -867,6 +867,14 @@ void a_UIcmd_back(void *vbw) a_Nav_back((BrowserWindow*)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 */ @@ -883,6 +891,14 @@ void a_UIcmd_forw(void *vbw) a_Nav_forw((BrowserWindow*)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 */ 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); -- cgit v1.2.3