1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-24 15:12:32 +01:00

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@kix.es>
This commit is contained in:
Rodolfo García Peñas (kix)
2015-08-23 20:56:59 +02:00
committed by Carlos R. Mafra
parent 8a822004ee
commit 7a2eb68aa4
3 changed files with 23 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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_ */