>From 134f4c043b05ee53d28043ddefa296fe844bfaf0 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 11:10:40 +0200
Subject: [PATCH 3/5] switchpanel default icon removed

The default icon (defIcon) is never used, because the function wDefaultGetImage
returns allways a icon (it search the default icon). So, we can remove the
defIcon variable, their creation and remove code.
---
 src/switchpanel.c |   35 +----------------------------------
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/src/switchpanel.c b/src/switchpanel.c
index 5966d9a..2b8930f 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -56,8 +56,6 @@ struct SwitchPanel {
 
        WMLabel *label;
 
-       RImage *defIcon;
-
        RImage *tileTmp;
        RImage *tile;
 
@@ -162,27 +160,6 @@ static RImage *scaleDownIfNeeded(RImage *image)
        return image;
 }
 
-/* This function sets the default icon (defIcon) in the switchpanel */
-static void create_default_icon(WSwitchPanel *panel)
-{
-       RImage *image = NULL;
-       char *path = NULL;
-       char *file = wDefaultGetIconFile(NULL, NULL, False);
-
-       if (file) {
-               path = FindImage(wPreferences.icon_path, file);
-               if (path) {
-                       image = RLoadImage(panel->scr->rcontext, path, 0);
-                       wfree(path);
-               }
-       }
-
-       if (image)
-               panel->defIcon = scaleDownIfNeeded(image);
-
-       image = NULL;
-}
-
 static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow 
*wwin, int x, int y)
 {
        WMFrame *icon = WMCreateFrame(parent);
@@ -195,18 +172,10 @@ static void addIconForWindow(WSwitchPanel *panel, 
WMWidget *parent, WWindow *wwi
        if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
                image = RRetainImage(wwin->net_icon_image);
 
+       /* If no image, get a new image (wDefaultGetImage includes the default 
icon image) */
        if (!image)
                image = wDefaultGetImage(panel->scr, wwin->wm_instance, 
wwin->wm_class, ICON_TILE_SIZE);
 
-       // Make this use a caching thing. When there are many windows,
-       // 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 && !panel->defIcon)
-               create_default_icon(panel);
-
-       if (!image && panel->defIcon)
-               image = RRetainImage(panel->defIcon);
-
        image = scaleDownIfNeeded(image);
 
        WMAddToArray(panel->images, image);
@@ -581,8 +550,6 @@ void wSwitchPanelDestroy(WSwitchPanel *panel)
                WMFreeArray(panel->icons);
 
        WMFreeArray(panel->windows);
-       if (panel->defIcon)
-               RReleaseImage(panel->defIcon);
 
        if (panel->tile)
                RReleaseImage(panel->tile);
-- 
1.7.10.4

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 134f4c043b05ee53d28043ddefa296fe844bfaf0 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 11:10:40 +0200
Subject: [PATCH 3/5] switchpanel default icon removed

The default icon (defIcon) is never used, because the function wDefaultGetImage
returns allways a icon (it search the default icon). So, we can remove the
defIcon variable, their creation and remove code.
---
 src/switchpanel.c |   35 +----------------------------------
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/src/switchpanel.c b/src/switchpanel.c
index 5966d9a..2b8930f 100644
--- a/src/switchpanel.c
+++ b/src/switchpanel.c
@@ -56,8 +56,6 @@ struct SwitchPanel {
 
 	WMLabel *label;
 
-	RImage *defIcon;
-
 	RImage *tileTmp;
 	RImage *tile;
 
@@ -162,27 +160,6 @@ static RImage *scaleDownIfNeeded(RImage *image)
 	return image;
 }
 
-/* This function sets the default icon (defIcon) in the switchpanel */
-static void create_default_icon(WSwitchPanel *panel)
-{
-	RImage *image = NULL;
-	char *path = NULL;
-	char *file = wDefaultGetIconFile(NULL, NULL, False);
-
-	if (file) {
-		path = FindImage(wPreferences.icon_path, file);
-		if (path) {
-			image = RLoadImage(panel->scr->rcontext, path, 0);
-			wfree(path);
-		}
-	}
-
-	if (image)
-		panel->defIcon = scaleDownIfNeeded(image);
-
-	image = NULL;
-}
-
 static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwin, int x, int y)
 {
 	WMFrame *icon = WMCreateFrame(parent);
@@ -195,18 +172,10 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
 	if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
 		image = RRetainImage(wwin->net_icon_image);
 
+	/* If no image, get a new image (wDefaultGetImage includes the default icon image) */
 	if (!image)
 		image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class, ICON_TILE_SIZE);
 
-	// Make this use a caching thing. When there are many windows,
-	// 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 && !panel->defIcon)
-		create_default_icon(panel);
-
-	if (!image && panel->defIcon)
-		image = RRetainImage(panel->defIcon);
-
 	image = scaleDownIfNeeded(image);
 
 	WMAddToArray(panel->images, image);
@@ -581,8 +550,6 @@ void wSwitchPanelDestroy(WSwitchPanel *panel)
 		WMFreeArray(panel->icons);
 
 	WMFreeArray(panel->windows);
-	if (panel->defIcon)
-		RReleaseImage(panel->defIcon);
 
 	if (panel->tile)
 		RReleaseImage(panel->tile);
-- 
1.7.10.4

Reply via email to