[WaylandWindow] Remove redundant icon fetcher query.

rofi_icon_fetcher is async, so we won't know which query succeeded on
the first try. All subsequent attempts use cached_icon_uid, and the
result of the first query will never be used.
Do the same as XCB window mode and request only lowercase app_id.
This commit is contained in:
Aleksei Bavshin 2022-11-23 16:44:05 -08:00 committed by lbonn
parent 2d6d3a2259
commit 42c6697a6b

View file

@ -586,30 +586,21 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
return NULL;
}
cairo_surface_t *icon = NULL;
gchar *transformed = NULL;
if (toplevel->cached_icon_uid > 0 && toplevel->cached_icon_size == height) {
return rofi_icon_fetcher_get(toplevel->cached_icon_uid);
}
/** lookup icon */
/**
* Lookup icon by lowercase app_id.
* There's no API to request multiple names, so we do the same as XCB window
* mode and search for a lowercase WM_CLASS/app_id.
*/
gchar *app_id_lower = g_utf8_strdown(toplevel->app_id, -1);
toplevel->cached_icon_size = height;
toplevel->cached_icon_uid = rofi_icon_fetcher_query(toplevel->app_id, height);
icon = rofi_icon_fetcher_get(toplevel->cached_icon_uid);
if (icon) {
return icon;
}
toplevel->cached_icon_uid = rofi_icon_fetcher_query(app_id_lower, height);
g_free(app_id_lower);
/** lookup icon by lowercase app_id */
transformed = g_utf8_strdown(toplevel->app_id, strlen(toplevel->app_id));
toplevel->cached_icon_uid = rofi_icon_fetcher_query(transformed, height);
icon = rofi_icon_fetcher_get(toplevel->cached_icon_uid);
g_free(transformed);
/* TODO: find desktop file by app_id and get the Icon= value */
return icon;
return rofi_icon_fetcher_get(toplevel->cached_icon_uid);
}
#include "mode-private.h"