From cedf6205435708b06e6b84c2cde41e2477cc99c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Wed, 6 Jun 2012 11:07:19 +0200 Subject: [PATCH] New function get_name_for_instance_class The function get_name_for_icon is renamed to get_name_for_wwin. The previous contents of get_name_for_icon are now at the new function get_name_for_instance_class. --- src/icon.c | 27 ++++++++++++++++----------- src/icon.h | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/icon.c b/src/icon.c index 27f4ebac..59161d39 100644 --- a/src/icon.c +++ b/src/icon.c @@ -398,23 +398,28 @@ Bool wIconChangeImageFile(WIcon * icon, char *file) return !error; } -char *get_name_for_icon(WWindow *wwin) +static char *get_name_for_wwin(WWindow *wwin) +{ + return get_name_for_instance_class(wwin->wm_instance, wwin->wm_class); +} + +char *get_name_for_instance_class(char *wm_instance, char *wm_class) { char *suffix; int len; - if (wwin->wm_class && wwin->wm_instance) { - len = strlen(wwin->wm_class) + strlen(wwin->wm_instance) + 2; + if (wm_class && wm_instance) { + len = strlen(wm_class) + strlen(wm_instance) + 2; suffix = wmalloc(len); - snprintf(suffix, len, "%s.%s", wwin->wm_instance, wwin->wm_class); - } else if (wwin->wm_class) { - len = strlen(wwin->wm_class) + 1; + snprintf(suffix, len, "%s.%s", wm_instance, wm_class); + } else if (wm_class) { + len = strlen(wm_class) + 1; suffix = wmalloc(len); - snprintf(suffix, len, "%s", wwin->wm_class); - } else if (wwin->wm_instance) { - len = strlen(wwin->wm_instance) + 1; + snprintf(suffix, len, "%s", wm_class); + } else if (wm_instance) { + len = strlen(wm_instance) + 1; suffix = wmalloc(len); - snprintf(suffix, len, "%s", wwin->wm_instance); + snprintf(suffix, len, "%s", wm_instance); } else { return NULL; } @@ -485,7 +490,7 @@ char *wIconStore(WIcon * icon) if (!dir_path) return NULL; - file = get_name_for_icon(wwin); + file = get_name_for_wwin(wwin); if (!file) { wfree(dir_path); return NULL; diff --git a/src/icon.h b/src/icon.h index 09b41903..62a18442 100644 --- a/src/icon.h +++ b/src/icon.h @@ -67,7 +67,8 @@ Bool wIconChangeImageFile(WIcon *icon, char *file); RImage * wIconValidateIconSize(WScreen *scr, RImage *icon, int max_size); -char * wIconStore(WIcon *icon); +char *wIconStore(WIcon *icon); +char *get_name_for_instance_class(char *wm_instance, char *wm_class); #ifdef NEWAPPICON void wIconSetHighlited(WIcon *icon, Bool flag);