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".
This commit is contained in:
lkn 2026-06-21 17:13:24 +02:00
parent 611a886582
commit bf552c9be2
2 changed files with 22 additions and 4 deletions

View File

@ -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"

View File

@ -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;
}