[Pkg-wmaker-commits] [wmaker] 09/21: Remove cache icon when detached

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jan 9 16:06:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository wmaker.

commit 7a2eb68aa47a35eede44457db5d300719be4dcdd
Author: Rodolfo García Peñas (kix) <kix at kix.es>
Date:   Sun Aug 23 20:56:59 2015 +0200

    Remove cache icon when detached
    
    This pach removes the icon from the icon cache when the icon is
    detached from the dock/clip.
    
    That helps to hold tidy the icon cache folder.
    
    -------8<-------
    Also app icon caching was broken around the same time. The app icon cache
    in CachedPixmaps was meant to store icons retrieved from X clients so the
    dock or clip can display those when the client is not running like after
    startup. The cache should contain only such icons and the path should never
    appear in WMWindowAttributes because the cache is an internal thing used to
    look up icons not otherwise available. If you look at your WMWindowAttributes
    now it is full of entries referring to the cache that should not be there and
    if you look at the cache dir you'll find a lot of icons from all apps you've
    ever started while there should be only the few docked ones that use client
    side icons. Also the cache is never cleaned up only new icons are added to it.
    -------8<-------
    
    Signed-off-by: Rodolfo García Peñas (kix) <kix at kix.es>
---
 src/dock.c |  4 ++++
 src/icon.c | 18 ++++++++++++++++++
 src/icon.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/src/dock.c b/src/dock.c
index e27b28a..3b3313b 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -2425,6 +2425,9 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
 
 	dock->icon_count--;
 
+	/* Remove the Cached Icon */
+	remove_cache_icon(icon->icon->file);
+
 	/* if the dock is not attached to an application or
 	 * the application did not set the appropriate hints yet,
 	 * destroy the icon */
@@ -2452,6 +2455,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
 		if (wPreferences.auto_arrange_icons)
 			wArrangeIcons(dock->screen_ptr, True);
 	}
+
 	if (dock->auto_collapse || dock->auto_raise_lower)
 		clipLeave(dock);
 }
diff --git a/src/icon.c b/src/icon.c
index d53f756..0dbd6ac 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -529,6 +529,24 @@ char *wIconStore(WIcon *icon)
 	return filename;
 }
 
+void remove_cache_icon(char *filename)
+{
+	char *cachepath;
+
+	if (!filename)
+		return;
+
+	cachepath = get_icon_cache_path();
+	if (!cachepath)
+		return;
+
+	/* Filename check/parse could be here */
+	if (!strncmp(filename, cachepath, strlen(cachepath)))
+		unlink(filename);
+
+	wfree(cachepath);
+}
+
 static void cycleColor(void *data)
 {
 	WIcon *icon = (WIcon *) data;
diff --git a/src/icon.h b/src/icon.h
index dbcb289..cccd7a8 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -80,4 +80,5 @@ void wIconSetHighlited(WIcon *icon, Bool flag);
 void set_icon_image_from_image(WIcon *icon, RImage *image);
 void set_icon_minipreview(WIcon *icon, RImage *image);
 
+void remove_cache_icon(char *filename);
 #endif /* WMICON_H_ */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmaker.git



More information about the Pkg-wmaker-commits mailing list