From 7a2eb68aa47a35eede44457db5d300719be4dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 23 Aug 2015 20:56:59 +0200 Subject: [PATCH] Remove cache icon when detached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- 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 e27b28ae..3b3313b2 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 d53f7564..0dbd6acb 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 dbcb2893..cccd7a86 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_ */