From b34137dde3bd40b5a116b4d8f86196027fc11d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 8 Sep 2024 18:25:07 +0200 Subject: [PATCH] toplevel-icon: set to app-id, instead of hardcoding to "foot" And, special case "footclient", and map it to "foot". --- render.c | 27 ++++++++++++++++++++++++--- wayland.c | 6 +++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/render.c b/render.c index 00ea3445..93bad7fe 100644 --- a/render.c +++ b/render.c @@ -4944,10 +4944,31 @@ render_refresh_app_id(struct terminal *term) }; timerfd_settime(term->render.app_id.timer_fd, 0, &timeout, NULL); - } else { - term->render.app_id.last_update = now; - xdg_toplevel_set_app_id(term->window->xdg_toplevel, term->app_id ? term->app_id : term->conf->app_id); + return; } + + const char *app_id = + term->app_id != NULL ? term->app_id : term->conf->app_id; + + xdg_toplevel_set_app_id(term->window->xdg_toplevel, app_id); + +#if defined(HAVE_XDG_TOPLEVEL_ICON) + if (term->wl->toplevel_icon_manager != NULL) { + struct xdg_toplevel_icon_v1 *icon = + xdg_toplevel_icon_manager_v1_create_icon( + term->wl->toplevel_icon_manager); + + xdg_toplevel_icon_v1_set_name( + icon, streq(app_id, "footclient") ? "foot" : app_id); + + xdg_toplevel_icon_manager_v1_set_icon( + term->wl->toplevel_icon_manager, term->window->xdg_toplevel, icon); + + xdg_toplevel_icon_v1_destroy(icon); + } +#endif + + term->render.app_id.last_update = now; } void diff --git a/wayland.c b/wayland.c index 30ee86c6..fd228312 100644 --- a/wayland.c +++ b/wayland.c @@ -1813,9 +1813,13 @@ wayl_win_init(struct terminal *term, const char *token) #if defined(HAVE_XDG_TOPLEVEL_ICON) if (wayl->toplevel_icon_manager != NULL) { + const char *app_id = + term->app_id != NULL ? term->app_id : term->conf->app_id; + struct xdg_toplevel_icon_v1 *icon = xdg_toplevel_icon_manager_v1_create_icon(wayl->toplevel_icon_manager); - xdg_toplevel_icon_v1_set_name(icon, "foot"); + xdg_toplevel_icon_v1_set_name(icon, streq( + app_id, "footclient") ? "foot" : app_id); xdg_toplevel_icon_manager_v1_set_icon( wayl->toplevel_icon_manager, win->xdg_toplevel, icon); xdg_toplevel_icon_v1_destroy(icon);