diff --git a/programs/dtwm/WmMcdePanel.c b/programs/dtwm/WmMcdePanel.c
index 64d9fc28..402a46a6 100644
--- a/programs/dtwm/WmMcdePanel.c
+++ b/programs/dtwm/WmMcdePanel.c
@@ -56,6 +56,37 @@
#include
#include
#include
+
+/* The icon of a program class. CDE names them with a capital (Dtterm,
+ * Dtcalc); a client's WM_CLASS instance name is often lower case and the
+ * class a kept program was written with may be either. Try the name as
+ * given, then in lower case, then with a capital -- the file name is what
+ * decides, not the comparison, which is strcasecmp. */
+static String
+ClassIcon(Screen *screen, const char *cls, unsigned int size)
+{
+ char lower[64], first[64];
+ String icon;
+ int i;
+
+ icon = _DtGetIconFileName(screen, (String) cls, NULL, NULL, size);
+ if (icon != NULL)
+ return icon;
+ for (i = 0; cls[i] != '\0' && i + 1 < (int) sizeof lower; i++)
+ lower[i] = (char) tolower((unsigned char) cls[i]);
+ lower[i] = '\0';
+ if (strcmp(lower, cls) != 0) {
+ icon = _DtGetIconFileName(screen, lower, NULL, NULL, size);
+ if (icon != NULL)
+ return icon;
+ }
+ if (cls[0] >= 'a' && cls[0] <= 'z') {
+ (void) snprintf(first, sizeof first, "%c%s",
+ cls[0] - 'a' + 'A', cls + 1);
+ icon = _DtGetIconFileName(screen, first, NULL, NULL, size);
+ }
+ return icon;
+}
#include
#define MAX_APPS 48
@@ -375,17 +406,8 @@ AddDrawerWidget(int idx)
below = kids[k - 1];
break;
}
- icon = _DtGetIconFileName(XtScreen(form), (String) drawerIcons[idx].cls,
- NULL, NULL, panel.sub_icon_size);
- if (icon == NULL) {
- for (i = 0; drawerIcons[idx].cls[i] != '\0' &&
- i + 1 < sizeof lower; i++)
- lower[i] = (char) tolower((unsigned char)
- drawerIcons[idx].cls[i]);
- lower[i] = '\0';
- icon = _DtGetIconFileName(XtScreen(form), lower, NULL, NULL,
- panel.sub_icon_size);
- }
+ icon = ClassIcon(XtScreen(form), drawerIcons[idx].cls,
+ panel.sub_icon_size);
if (icon == NULL)
icon = GetIconName("Dtactn", panel.sub_icon_size);
XtSetArg(al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
@@ -936,15 +958,7 @@ AddButton(const char *cls, int keptIndex)
return;
/* the class's icon, as CDE names them (Dtterm, Dtcalc), else in
* lower case, else the icon of an action */
- icon = _DtGetIconFileName(XtScreen(area), (String) cls, NULL, NULL,
- panel.main_icon_size);
- if (icon == NULL) {
- for (i = 0; cls[i] != '\0' && i + 1 < sizeof lower; i++)
- lower[i] = (char) tolower((unsigned char) cls[i]);
- lower[i] = '\0';
- icon = _DtGetIconFileName(XtScreen(area), lower, NULL, NULL,
- panel.main_icon_size);
- }
+ icon = ClassIcon(XtScreen(area), cls, panel.main_icon_size);
if (icon == NULL)
icon = GetIconName("Dtactn", panel.main_icon_size);
XtSetArg(al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;