From 0cb07027f2f1e5035cc009140084128d35995c54 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 8 Sep 2024 13:15:21 +0200 Subject: wayland: set toplevel icon If the xdg-toplevel-icon-v1 protocol is available, and we have the corresponding manager global, set the toplevel icon to "foot". Note: we do *not* provide any pixel data. This is by design; we want to keep things simple. To be able to provide pixel data, we would have to either: * embed the raw pixel data in the foot binary * link against either libpng or/and e.g. nanosvg, locate, at run-time, the paths to our own icons, and load them at run-time. * link against either libpng or/and e.g. nanosvg, and, at run-time, do a full icon lookup. This would also require us to add a config option for which icon theme to use. Of the two, I would prefer the first option. But, let's skip this completely for now. By providing the icon as a name, the compositor will have to lookup the icon itself. Compositors supporting icons is likely to already support this. So what do we gain by implementing this protocol? Compositors no longer has to parse .desktop files and map our app-id to find the icon to use. There's one question remaining. With this patch, the icon name is hardcoded to "foot", just like our .desktop files. But, perhaps we should use the app-id instead? And if so, should we also change the icon when the app-id changes? My gut feeling is, yes, we should use the app-id instead, and yes, we should update the icon when the app-id is changed at run-time. --- wayland.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wayland.c b/wayland.c index 1e98560a..30ee86c6 100644 --- a/wayland.c +++ b/wayland.c @@ -1811,6 +1811,17 @@ wayl_win_init(struct terminal *term, const char *token) xdg_toplevel_set_app_id(win->xdg_toplevel, conf->app_id); +#if defined(HAVE_XDG_TOPLEVEL_ICON) + if (wayl->toplevel_icon_manager != NULL) { + 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_manager_v1_set_icon( + wayl->toplevel_icon_manager, win->xdg_toplevel, icon); + xdg_toplevel_icon_v1_destroy(icon); + } +#endif + if (conf->csd.preferred == CONF_CSD_PREFER_NONE) { /* User specifically do *not* want decorations */ win->csd_mode = CSD_NO; -- cgit v1.3