commit 0e7b2e99bcc7b27a70cab7a553746ca3ed98ccac from: Omar Polo date: Thu May 05 11:20:46 2022 UTC rate-limit the update of the download pane commit - 89e4650865dd63b981f91873704f3883ed20aa05 commit + 0e7b2e99bcc7b27a70cab7a553746ca3ed98ccac blob - 83f4588888e274692672a22226766cde1fe60baf blob + d8d4d7edf70df62136d77dd6a30f731ab068b9c6 --- ChangeLog +++ ChangeLog @@ -1,3 +1,8 @@ +2022-05-05 Omar Polo + + * ui.c (ui_on_download_refresh): rate-limit the update of the + download pane + 2022-04-24 Omar Polo * session.c (save_session): generate session and histfile atomically blob - 605da51f8dec8e5d9ea30481d277de1ba61cce50 blob + a7027a900ad35ef00aa79dd94069de4f2190e7fe --- ui.c +++ ui.c @@ -58,6 +58,7 @@ static int readkey(void); static void dispatch_stdio(int, short, void*); static void handle_resize(int, short, void*); static void handle_resize_nodelay(int, short, void*); +static void handle_download_refresh(int, short, void *); static void rearrange_windows(void); static void line_prefix_and_text(struct vline *, char *, size_t, const char **, const char **); static void print_vline(int, int, WINDOW*, struct vline*); @@ -87,6 +88,9 @@ struct tab *current_tab; static struct event resizeev; static struct timeval resize_timer = { 0, 250000 }; +static struct event download_refreshev; +static struct timeval download_refresh_timer = { 0, 250000 }; + static WINDOW *tabline, *body, *modeline, *echoarea, *minibuffer; int body_lines, body_cols; @@ -354,6 +358,15 @@ handle_resize_nodelay(int s, short ev, void *d) rearrange_windows(); } +static void +handle_download_refresh(int s, short v, void *d) +{ + if (side_window & SIDE_WINDOW_BOTTOM) { + recompute_downloads(); + redraw_tab(current_tab); + } +} + static inline int should_show_tab_bar(void) { @@ -1191,6 +1204,7 @@ void ui_main_loop(void) { evtimer_set(&resizeev, handle_resize, NULL); + evtimer_set(&download_refreshev, handle_download_refresh, NULL); event_set(&stdioev, 0, EV_READ | EV_PERSIST, dispatch_stdio, NULL); event_add(&stdioev, NULL); @@ -1238,10 +1252,11 @@ ui_on_tab_refresh(struct tab *tab) void ui_on_download_refresh(void) { - if (side_window & SIDE_WINDOW_BOTTOM) { - recompute_downloads(); - redraw_tab(current_tab); - } + if (event_pending(&download_refreshev, EV_TIMEOUT, NULL)) + return; + + evtimer_set(&download_refreshev, handle_download_refresh, NULL); + evtimer_add(&download_refreshev, &download_refresh_timer); } void