Icons in the switchpanel look silly if the IconSize preference is set to less than 64x64 because they are drawn at the configured size but spaced in a grid which assumes they are still 64x64.

This patch forces the switchpanel to load icons at 64x64 regardless of the configured size used elsewhere.

I did play around with making the switchpanel size independently configurable. It worked but looked bad at anything other than 64x64 so I discarded that idea.

Aside: wmaker needs to be restarted to see the affect of changing IconSize.
From 2fddf3501d9b8ba2a531e3f5b75b33950cbed990 Mon Sep 17 00:00:00 2001
From: Iain Patterson <w...@iain.cx>
Date: Tue, 14 Feb 2012 13:13:55 +0000
Subject: [PATCH] Don't shrink icons in switchpanel.

Icons in the switchpanel are constrained to the value of the IconSize
preference but the grid in which they are arranged is fixed at 64 pixels.
If IconSize is less than 64x64 the panel will show smaller icons with a
wide spacing, which looks pretty stupid.

Fix it by forcing the switchpanel to attempt to load images at the size
it's going to use.  The icon it actually gets may of course still be
smaller.
---
 src/defaults.c    |    2 +-
 src/defaults.h    |    2 +-
 src/icon.c        |   16 ++++++++--------
 src/icon.h        |    2 +-
 src/screen.c      |    2 +-
 src/switchpanel.c |    2 +-
 src/wdefaults.c   |    4 ++--
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/defaults.c b/src/defaults.c
index 70a372a..6e73ec8 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -964,7 +964,7 @@ void wDefaultsCheckDomains(void* arg)
                                                /* Update the panel image if 
changed */
                                                /* Don't worry. If the image is 
the same these
                                                 * functions will have no 
performance impact. */
-                                               image = wDefaultGetImage(scr, 
"Logo", "WMPanel");
+                                               image = wDefaultGetImage(scr, 
"Logo", "WMPanel", wPreferences.icon_size);
 
                                                if (!image) {
                                                        wwarning(_("could not 
load logo image for panels: %s"),
diff --git a/src/defaults.h b/src/defaults.h
index 2dcf339..fdf09cd 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -52,7 +52,7 @@ void wSaveDefaults(WScreen *scr);
 char *wDefaultGetIconFile(WScreen *scr, char *instance, char *class,
                           Bool noDefault);
 
-RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass);
+RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int 
max_size);
 
 void wDefaultFillAttributes(WScreen *scr, char *instance, char *class,
                             WWindowAttributes *attr, WWindowAttributes *mask,
diff --git a/src/icon.c b/src/icon.c
index 5660d6b..be1b3a7 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -154,7 +154,7 @@ WIcon *wIconCreate(WWindow * wwin)
 #else
        icon->show_title = 1;
 #endif
-       icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, 
wwin->wm_class);
+       icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, 
wwin->wm_class, wPreferences.icon_size);
 
        file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, 
False);
        if (file) {
@@ -215,7 +215,7 @@ WIcon *wIconCreateWithIconFile(WScreen * scr, char 
*iconfile, int tile)
                        wwarning(_("error loading image file \"%s\": %s"), 
iconfile, RMessageForError(RErrorCode));
                }
 
-               icon->file_image = wIconValidateIconSize(scr, icon->file_image);
+               icon->file_image = wIconValidateIconSize(scr, icon->file_image, 
wPreferences.icon_size);
 
                icon->file = wstrdup(iconfile);
        }
@@ -354,7 +354,7 @@ void wIconChangeTitle(WIcon * icon, char *new_title)
        wIconPaint(icon);
 }
 
-RImage *wIconValidateIconSize(WScreen * scr, RImage * icon)
+RImage *wIconValidateIconSize(WScreen * scr, RImage * icon, int max_size)
 {
        RImage *tmp;
        int w, h;
@@ -362,9 +362,9 @@ RImage *wIconValidateIconSize(WScreen * scr, RImage * icon)
        if (!icon)
                return NULL;
 #ifndef DONT_SCALE_ICONS
-       if (wPreferences.icon_size != 64) {
-               w = wPreferences.icon_size * icon->width / 64;
-               h = wPreferences.icon_size * icon->height / 64;
+       if (max_size != 64) {
+               w = max_size * icon->width / 64;
+               h = max_size * icon->height / 64;
 
                tmp = RScaleImage(icon, w, h);
                RReleaseImage(icon);
@@ -394,7 +394,7 @@ Bool wIconChangeImageFile(WIcon * icon, char *file)
        path = FindImage(wPreferences.icon_path, file);
 
        if (path && (image = RLoadImage(scr->rcontext, path, 0))) {
-               icon->file_image = 
wIconValidateIconSize(icon->core->screen_ptr, image);
+               icon->file_image = 
wIconValidateIconSize(icon->core->screen_ptr, image, wPreferences.icon_size);
                wIconUpdate(icon);
        } else {
                error = 1;
@@ -706,7 +706,7 @@ void wIconUpdate(WIcon * icon)
                                }
  make_icons:
 
-                               image = wIconValidateIconSize(scr, image);
+                               image = wIconValidateIconSize(scr, image, 
wPreferences.icon_size);
                                scr->def_icon_pixmap = makeIcon(scr, image, 
False, False, icon->tile_type, icon->highlighted);
                                scr->def_ticon_pixmap = makeIcon(scr, image, 
True, False, icon->tile_type, icon->highlighted);
                                if (image)
diff --git a/src/icon.h b/src/icon.h
index d0f87ec..9786995 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -66,7 +66,7 @@ void wIconChangeTitle(WIcon *icon, char *new_title);
 Bool wIconChangeImageFile(WIcon *icon, char *file);
 void wIconSelect(WIcon *icon);
 
-RImage *wIconValidateIconSize(WScreen *scr, RImage *icon);
+RImage *wIconValidateIconSize(WScreen *scr, RImage *icon, int max_size);
 
 char *wIconStore(WIcon *icon);
 
diff --git a/src/screen.c b/src/screen.c
index e2cda33..5c12147 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -402,7 +402,7 @@ static void createPixmaps(WScreen * scr)
                pix->shared = 1;
        scr->menu_shade_indicator = pix;
 
-       image = wDefaultGetImage(scr, "Logo", "WMPanel");
+       image = wDefaultGetImage(scr, "Logo", "WMPanel", 
wPreferences.icon_size);
 
        if (!image) {
                wwarning(_("could not load logo image for panels: %s"), 
RMessageForError(RErrorCode));
diff --git a/src/switchpanel.c b/src/switchpanel.c
index 3836991..aac3a22 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -177,7 +177,7 @@ static void addIconForWindow(WSwitchPanel * panel, WMWidget 
* parent, WWindow *
        // it's very likely that most of them are instances of the same thing,
        // so caching them should get performance acceptable in these cases.
        if (!image)
-               image = wDefaultGetImage(panel->scr, wwin->wm_instance, 
wwin->wm_class);
+               image = wDefaultGetImage(panel->scr, wwin->wm_instance, 
wwin->wm_class, ICON_TILE_SIZE);
 
        if (!image && !panel->defIcon) {
                char *file = wDefaultGetIconFile(panel->scr, NULL, NULL, False);
diff --git a/src/wdefaults.c b/src/wdefaults.c
index 8df9dc8..ee42d00 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -399,7 +399,7 @@ char *wDefaultGetIconFile(WScreen * scr, char *instance, 
char *class, Bool noDef
        return tmp;
 }
 
-RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass)
+RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int 
max_size)
 {
        char *file_name;
        char *path;
@@ -422,7 +422,7 @@ RImage *wDefaultGetImage(WScreen * scr, char *winstance, 
char *wclass)
        }
        wfree(path);
 
-       image = wIconValidateIconSize(scr, image);
+       image = wIconValidateIconSize(scr, image, max_size);
 
        return image;
 }
-- 
1.7.7.6

Reply via email to