Avoid some unneeded refilters when icons updates.

This commit is contained in:
Dave Davenport 2023-07-28 21:15:50 +02:00
parent 82f9605c30
commit d847629e92
6 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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,

View File

@ -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) {