aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-09-08 11:15:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-09-13 07:04:17 +0000
commit0cb07027f2f1e5035cc009140084128d35995c54 (patch)
treecf9903ff72fcff29a16eb93e700eb122d859b1d2
parentwayland: bind the xdg-toplevel-icon manager global (diff)
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.
-rw-r--r--wayland.c11
1 files changed, 11 insertions, 0 deletions
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;