diff options
author | Dave Davenport <qball@gmpclient.org> | 2023-07-28 21:15:50 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2023-07-28 21:15:50 +0200 |
commit | d847629e927caef276646233043cbfc4287f9723 (patch) | |
tree | 8e3d70c45dac84bd54ae8ee27a80ffc0865117b8 | |
parent | 82f9605c30e0765816aa23384edf9f99f68e4544 (diff) |
Avoid some unneeded refilters when icons updates.less-refiltering
-rw-r--r-- | include/view.h | 4 | ||||
-rw-r--r-- | source/modes/dmenu.c | 2 | ||||
-rw-r--r-- | source/modes/recursivebrowser.c | 2 | ||||
-rw-r--r-- | source/modes/window.c | 2 | ||||
-rw-r--r-- | source/rofi-icon-fetcher.c | 8 | ||||
-rw-r--r-- | source/view.c | 8 |
6 files changed, 15 insertions, 11 deletions
diff --git a/include/view.h b/include/view.h index 783d6f4a..441abb9b 100644 --- a/include/view.h +++ b/include/view.h @@ -257,12 +257,13 @@ Mode *rofi_view_get_mode(RofiViewState *state); void rofi_view_hide(void); /** + * @param refilter The reload needs to refilter the rows. * Indicate the current view needs to reload its data. * This can only be done when *more* information is available. * * The reloading happens 'lazy', multiple calls might be handled at once. */ -void rofi_view_reload(void); +void rofi_view_reload(gboolean refilter); /** * @param state The handle to the view @@ -370,6 +371,5 @@ gboolean rofi_set_im_window_pos(int new_x, int new_y); WidgetTriggerActionResult textbox_button_trigger_action( widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data); - /** @} */ #endif diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c index 41841074..124fa4d7 100644 --- a/source/modes/dmenu.c +++ b/source/modes/dmenu.c @@ -225,7 +225,7 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition, changed = TRUE; } if (changed) { - rofi_view_reload(); + rofi_view_reload(TRUE); } } else if (command == 'q') { if (pd->loading) { diff --git a/source/modes/recursivebrowser.c b/source/modes/recursivebrowser.c index 3e010b41..4be32bb1 100644 --- a/source/modes/recursivebrowser.c +++ b/source/modes/recursivebrowser.c @@ -291,7 +291,7 @@ static gboolean recursive_browser_async_read_proc(gint fd, changed = TRUE; } if (changed) { - rofi_view_reload(); + rofi_view_reload(TRUE); } } else if (command == 'q') { if (pd->loading) { diff --git a/source/modes/window.c b/source/modes/window.c index 1d93e957..aec9616b 100644 --- a/source/modes/window.c +++ b/source/modes/window.c @@ -403,7 +403,7 @@ static gboolean window_client_reload(G_GNUC_UNUSED void *data) { window_mode_cd._init(&window_mode_cd); } if (window_mode.private_data || window_mode_cd.private_data) { - rofi_view_reload(); + rofi_view_reload(TRUE); } return G_SOURCE_REMOVE; } diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 120ebee1..b19acab5 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -319,7 +319,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, cairo_destroy(cr); sentry->surface = surface; sentry->query_done = TRUE; - rofi_view_reload(); + rofi_view_reload(FALSE); return; } else { @@ -338,7 +338,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, } if (icon_path_ == NULL) { sentry->query_done = TRUE; - rofi_view_reload(); + rofi_view_reload(FALSE); return; } } else { @@ -352,7 +352,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, if (suf == NULL) { sentry->query_done = TRUE; g_free(icon_path_); - rofi_view_reload(); + rofi_view_reload(FALSE); return; } @@ -373,7 +373,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, sentry->surface = icon_surf; g_free(icon_path_); sentry->query_done = TRUE; - rofi_view_reload(); + rofi_view_reload(FALSE); } uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, diff --git a/source/view.c b/source/view.c index ecf095c6..a8be46e2 100644 --- a/source/view.c +++ b/source/view.c @@ -511,7 +511,6 @@ static gboolean rofi_view_reload_idle(G_GNUC_UNUSED gpointer data) { g_free(r); } current_active_menu->reload = TRUE; - current_active_menu->refilter = TRUE; rofi_view_queue_redraw(); } CacheState.idle_timeout = 0; @@ -560,11 +559,16 @@ static void rofi_view_set_user_timeout(G_GNUC_UNUSED gpointer data) { } } -void rofi_view_reload(void) { +void rofi_view_reload(gboolean refilter) { // @TODO add check if current view is equal to the callee if (CacheState.idle_timeout == 0) { CacheState.idle_timeout = g_timeout_add(1000 / 100, rofi_view_reload_idle, NULL); + // @TODO this can be called from a separate thread (not at the moment, as + // that usecase refilter == FALSE) Should we add a lock for this? + if ( refilter && current_active_menu) { + current_active_menu->refilter = TRUE; + } } } void rofi_view_queue_redraw(void) { |