diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-10-25 18:47:07 +0200 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-10-28 19:04:33 +0100 |
commit | 27f88f0e81fd66b59e52af7ec2a725d8bfd4351c (patch) | |
tree | 71ad549fd6a8ffb1b202ce95e3f60dcdd49469fd /src/uicmd.cc | |
parent | 6d5b3ee329b61adfa144c4f7f9d60bbe10e04071 (diff) |
Reload the current page on SIGUSR1 signal
Reloads the current page on all windows when the SIGUSR1 is received.
This is useful to update the page when it is being edited.
Fixes: https://github.com/dillo-browser/dillo/issues/255
Diffstat (limited to 'src/uicmd.cc')
-rw-r--r-- | src/uicmd.cc | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/uicmd.cc b/src/uicmd.cc index 5cd0d887..18ac2ff1 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -69,6 +69,15 @@ using namespace dw::fltk; */ static const char *save_dir = ""; +struct Tabgroup { + CustTabs *tabs; + struct Tabgroup *next; +}; + +/* An stack of CustTabs groups, each maps to one FLTK window. Points to + * the last one created. */ +static struct Tabgroup *tabgroups = NULL; + /* * Forward declarations */ @@ -570,6 +579,13 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, win->box(FL_NO_BOX); CustTabs *DilloTabs = new CustTabs(ww, wh, prefs.ui_tab_height); + + struct Tabgroup *tg = new Tabgroup; + tg->tabs = DilloTabs; + tg->next = tabgroups; + tabgroups = tg; + _MSG("new: tabgroups=%p\n", (void *) tg); + win->end(); win->resizable(DilloTabs->wizard()); @@ -668,8 +684,26 @@ void a_UIcmd_close_bw(void *vbw) delete(layout); if (tabs) { tabs->remove_tab(ui); - if (tabs->num_tabs() == 0) + if (tabs->num_tabs() == 0) { + /* No more tabs, remove tabgroup */ + struct Tabgroup *tmp = tabgroups; + struct Tabgroup *prev = NULL; + for (tmp = tabgroups; tmp; tmp = tmp->next) { + if (tmp->tabs == tabs) { + if (prev) + prev->next = tmp->next; + else + tabgroups = tmp->next; + break; + } + prev = tmp; + } + if (tmp) { + _MSG("gone: tmp=%p tabgroups=%p\n", (void *) tmp, (void *) tabgroups); + delete tmp; + } delete tabs->window(); + } } a_Bw_free(bw); } @@ -874,6 +908,19 @@ void a_UIcmd_reload(void *vbw) } /* + * Reload all active tabs + */ +void a_UIcmd_reload_all_active() +{ + struct Tabgroup *tg = tabgroups; + for (tg = tabgroups; tg; tg = tg->next) { + BrowserWindow *bw = a_UIcmd_get_bw_by_widget(tg->tabs->wizard()->value()); + if (bw) + a_UIcmd_reload(bw); + } +} + +/* * Repush current URL */ void a_UIcmd_repush(void *vbw) |