>From 269670e9501af75046042f5dd6e2a68020a68a40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 15 Jul 2012 21:28:00 +0200
Subject: [PATCH 2/3] Removed scaleDownIfNeeded function (dup code)

The function scaleDownIfNeeded's code is duplicated with the code of
wIconValidateIconSize(), then this function can be removed. The icon
size in the switchpanel should be ~48 pixels, to allow the frame around
the icon. Then, we always should resize the icon to this size. The standard
icon size is specified in WPreferences.icon_size (usually 64 pixels).
---
 src/switchpanel.c |   16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/switchpanel.c b/src/switchpanel.c
index 2b8930f..320ae63 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -27,6 +27,7 @@
 #include "WindowMaker.h"
 #include "screen.h"
 #include "framewin.h"
+#include "icon.h"
 #include "window.h"
 #include "defaults.h"
 #include "switchpanel.h"
@@ -148,18 +149,6 @@ static void changeImage(WSwitchPanel *panel, int idecks, 
int selected)
                WMSetFrameRelief(icon, WRSimple);
 }
 
-static RImage *scaleDownIfNeeded(RImage *image)
-{
-       if (image && ((image->width - ICON_SIZE) > 2 || (image->height - 
ICON_SIZE) > 2)) {
-               RImage *nimage;
-               nimage = RScaleImage(image, ICON_SIZE, (image->height * 
ICON_SIZE / image->width));
-               RReleaseImage(image);
-               image = nimage;
-       }
-
-       return image;
-}
-
 static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow 
*wwin, int x, int y)
 {
        WMFrame *icon = WMCreateFrame(parent);
@@ -176,7 +165,8 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget 
*parent, WWindow *wwi
        if (!image)
                image = wDefaultGetImage(panel->scr, wwin->wm_instance, 
wwin->wm_class, ICON_TILE_SIZE);
 
-       image = scaleDownIfNeeded(image);
+       /* We must resize the icon size (~64) to the switchpanel icon size 
(~48) */
+       image = wIconValidateIconSize(image, ICON_SIZE);
 
        WMAddToArray(panel->images, image);
        WMAddToArray(panel->icons, icon);
-- 
1.7.10.4

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 269670e9501af75046042f5dd6e2a68020a68a40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sun, 15 Jul 2012 21:28:00 +0200
Subject: [PATCH 2/3] Removed scaleDownIfNeeded function (dup code)

The function scaleDownIfNeeded's code is duplicated with the code of
wIconValidateIconSize(), then this function can be removed. The icon
size in the switchpanel should be ~48 pixels, to allow the frame around
the icon. Then, we always should resize the icon to this size. The standard
icon size is specified in WPreferences.icon_size (usually 64 pixels).
---
 src/switchpanel.c |   16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/switchpanel.c b/src/switchpanel.c
index 2b8930f..320ae63 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -27,6 +27,7 @@
 #include "WindowMaker.h"
 #include "screen.h"
 #include "framewin.h"
+#include "icon.h"
 #include "window.h"
 #include "defaults.h"
 #include "switchpanel.h"
@@ -148,18 +149,6 @@ static void changeImage(WSwitchPanel *panel, int idecks, int selected)
 		WMSetFrameRelief(icon, WRSimple);
 }
 
-static RImage *scaleDownIfNeeded(RImage *image)
-{
-	if (image && ((image->width - ICON_SIZE) > 2 || (image->height - ICON_SIZE) > 2)) {
-		RImage *nimage;
-		nimage = RScaleImage(image, ICON_SIZE, (image->height * ICON_SIZE / image->width));
-		RReleaseImage(image);
-		image = nimage;
-	}
-
-	return image;
-}
-
 static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwin, int x, int y)
 {
 	WMFrame *icon = WMCreateFrame(parent);
@@ -176,7 +165,8 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
 	if (!image)
 		image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class, ICON_TILE_SIZE);
 
-	image = scaleDownIfNeeded(image);
+	/* We must resize the icon size (~64) to the switchpanel icon size (~48) */
+	image = wIconValidateIconSize(image, ICON_SIZE);
 
 	WMAddToArray(panel->images, image);
 	WMAddToArray(panel->icons, icon);
-- 
1.7.10.4

Reply via email to