From bf552c9be2eff39aead9bab798a03d2f61175809 Mon Sep 17 00:00:00 2001 From: lkn Date: Sun, 21 Jun 2026 17:13:24 +0200 Subject: [PATCH] appicon: use wm_class (app_id) in kill dialog instead of wm_instance For Wayland clients, wm_instance is the window title (often long and non-descriptive for identification) while wm_class is the app_id which is the application identifier. Prefer wm_class for the kill confirmation dialog, falling back to basename(wm_instance) then "application". --- src/appicon.c | 17 ++++++++++++++++- src/backend/wayland/wl_props.c | 9 ++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 9e83491..19277e5 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -522,7 +522,22 @@ static void killCallback(WMenu * menu, WMenuEntry * entry) assert(entry->clientdata != NULL); - shortname = basename(wapp->app_icon->wm_instance); + { + WWindow *desc = wapp->main_window_desc; + WIcon *_ic = wapp->app_icon ? wapp->app_icon->icon : NULL; + WWindow *owner = _ic ? _ic->owner : NULL; + if (!owner) owner = desc; + if (owner && owner->wm_class && strcmp(owner->wm_class, "wayland-client") != 0) + shortname = owner->wm_class; + else if (owner && owner->wm_instance && strcmp(owner->wm_instance, "wayland-client") != 0) + shortname = owner->wm_instance; + else if (owner && owner->frame && owner->frame->title) + shortname = owner->frame->title; + else if (desc && desc->frame && desc->frame->title) + shortname = desc->frame->title; + else + shortname = "application"; + } buffer = wstrconcat(wapp->app_icon ? shortname : NULL, _(" will be forcibly closed.\n" diff --git a/src/backend/wayland/wl_props.c b/src/backend/wayland/wl_props.c index 841a7c1..cebff6a 100644 --- a/src/backend/wayland/wl_props.c +++ b/src/backend/wayland/wl_props.c @@ -90,9 +90,12 @@ wl_prop_get_wm_class(WNativeWindow win, } const char *app_id = (v && v->xdg_surface && v->xdg_surface->toplevel && v->xdg_surface->toplevel->app_id) - ? v->xdg_surface->toplevel->app_id : "wayland-client"; - *wm_class = strdup(app_id); - *wm_instance = strdup(app_id); + ? v->xdg_surface->toplevel->app_id : NULL; + const char *title = (v && v->xdg_surface && v->xdg_surface->toplevel && + v->xdg_surface->toplevel->title) + ? v->xdg_surface->toplevel->title : NULL; + *wm_class = strdup(app_id ? app_id : (title ? title : "wayland-client")); + *wm_instance = strdup(title ? title : (app_id ? app_id : "wayland-client")); return 1; }