Hi,

I had an idea about the function icon_update_pixmap() what do you think about 
it?

The main idea is validate the icon size first, using wIconValidateIconSize, 
therefore the icon has a correct value and a lot of ugly code can be removed. 
This is a patch test, no a final patch. Is based in my latest patches, but you 
can easily apply to the current branch next/master.

Comments are welcome.  Thanks.

kix


diff --git a/src/icon.c b/src/icon.c
index 7a9e849..bdf2726 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -274,11 +274,8 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
 {
        RImage *tile;
        Pixmap pixmap;
-       int x, y, sx, sy;
-       unsigned w, h;
-       int theight = 0;
+       int x, y, theight = 0;
        WScreen *scr = icon->core->screen_ptr;
-       int titled = icon->show_title;
 
        if (icon->tile_type == TILE_NORMAL) {
                tile = RCloneImage(scr->icon_tile);
@@ -288,20 +285,15 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
        }
 
        if (image) {
-               w = (image->width > wPreferences.icon_size)
-                   ? wPreferences.icon_size : image->width;
-               x = (wPreferences.icon_size - w) / 2;
-               sx = (image->width - w) / 2;
+               image = wIconValidateIconSize(image, wPreferences.icon_size);
 
-               if (titled)
+               if (icon->show_title)
                        theight = WMFontHeight(scr->icon_title_font);
 
-               h = (image->height + theight > wPreferences.icon_size
-                    ? wPreferences.icon_size - theight : image->height);
-               y = theight + (wPreferences.icon_size - theight - h) / 2;
-               sy = (image->height - h) / 2;
+               x = (wPreferences.icon_size - image->width) / 2;
+               y = theight + (wPreferences.icon_size - theight - 
image->height) / 2;
 
-               RCombineArea(tile, image, sx, sy, w, h, x, y);
+               RCombineArea(tile, image, 0, 0, image->width, image->height, x, 
y);
        }
 
        if (icon->shadowed) {
@@ -327,7 +319,7 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
 
        RReleaseImage(tile);
 
-       if (titled)
+       if (icon->show_title)
                drawIconTitle(scr, pixmap, theight);
 
        icon->pixmap = pixmap;

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to [email protected].

Reply via email to