From a396f3bd662e36dd464e9b0a8880f960ba5891ec Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 8 Oct 2010 15:08:34 -0400 Subject: [PATCH] Only cache pixmaps for docked icons There is little point caching a pixmap for an app that isn't in the dock. This patch creates a function wAppIconSave that saves only if the app icon is docked, and adds calls to that function in all the places where an appicon can transition from undocked to docked. It also "adds" a function wApplicationSaveIconPathFor that saves an icon path to the configuration plist; the function already existed, it was just static before. Signed-off-by: Brad Jorsch --- src/appicon.c | 17 +++++++++++++++++ src/appicon.h | 2 ++ src/application.c | 24 +++++------------------- src/application.h | 2 ++ src/dock.c | 7 ++++++- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 0872e21b..b08c8f11 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -30,6 +30,7 @@ #include "WindowMaker.h" #include "window.h" #include "icon.h" +#include "application.h" #include "appicon.h" #include "actions.h" #include "stacking.h" @@ -280,6 +281,22 @@ void wAppIconPaint(WAppIcon * aicon) } } +Bool wAppIconSave(WAppIcon *aicon) +{ + char *path; + + if (!aicon->docked || aicon->attracted) return True; + + path = wIconStore(aicon->icon); + if (!path) + return False; + + wApplicationSaveIconPathFor(path, aicon->wm_instance, aicon->wm_class); + + wfree(path); + return True; +} + #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance)) static void hideCallback(WMenu * menu, WMenuEntry * entry) diff --git a/src/appicon.h b/src/appicon.h index 391c9cc5..f10f847e 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -95,5 +95,7 @@ Bool wAppIconChangeImage(WAppIcon *icon, char *file); void wAppIconMove(WAppIcon *aicon, int x, int y); +Bool wAppIconSave(WAppIcon *aicon); + #endif diff --git a/src/application.c b/src/application.c index 187eccab..fad91869 100644 --- a/src/application.c +++ b/src/application.c @@ -121,7 +121,7 @@ static void extractIcon(WWindow * wwin) } } -static void saveIconNameFor(char *iconPath, char *wm_instance, char *wm_class) +void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_class) { WMPropList *dict = WDWindowAttributes->dictionary; WMPropList *adict, *key, *iconk; @@ -202,27 +202,12 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance } if (iconPath) { - saveIconNameFor(iconPath, wm_instance, wm_class); + wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class); wfree(iconPath); } } -static Bool extractClientIcon(WAppIcon * icon) -{ - char *path; - - path = wIconStore(icon->icon); - if (!path) - return False; - - saveIconNameFor(path, icon->wm_instance, icon->wm_class); - - wfree(path); - - return True; -} - WApplication *wApplicationCreate(WWindow * wwin) { WScreen *scr = wwin->screen_ptr; @@ -324,6 +309,7 @@ WApplication *wApplicationCreate(WWindow * wwin) if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint)) wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; wAppIconPaint(wapp->app_icon); + wAppIconSave(wapp->app_icon); } else { wapp->app_icon = wAppIconCreate(wapp->main_window_desc); } @@ -381,8 +367,8 @@ WApplication *wApplicationCreate(WWindow * wwin) } /* if the displayed icon was supplied by the client, save the icon */ - if (!tmp) - extractClientIcon(wapp->app_icon); + if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL) + wAppIconSave(wapp->app_icon); } return wapp; } diff --git a/src/application.h b/src/application.h index a2766fea..298e3759 100644 --- a/src/application.h +++ b/src/application.h @@ -58,6 +58,8 @@ WApplication *wApplicationOf(Window window); void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, char *wm_class); +void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, + char *wm_class); void wAppBounce(WApplication *); void wAppBounceWhileUrgent(WApplication *); diff --git a/src/dock.c b/src/dock.c index 596c1b97..736823cc 100644 --- a/src/dock.c +++ b/src/dock.c @@ -575,6 +575,7 @@ static void keepIconsCallback(WMenu * menu, WMenuEntry * entry) wAppIconPaint(aicon); } } + wAppIconSave(aicon); } WMFreeArray(selectedIcons); } @@ -1207,8 +1208,10 @@ static void dockIconPaint(WAppIcon * btn) { if (btn == btn->icon->core->screen_ptr->clip_icon) wClipIconPaint(btn); - else + else { wAppIconPaint(btn); + wAppIconSave(btn); + } } static WMPropList *make_icon_state(WAppIcon * btn) @@ -2019,6 +2022,7 @@ Bool wDockAttachIcon(WDock * dock, WAppIcon * icon, int x, int y) MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core); wAppIconMove(icon, icon->x_pos, icon->y_pos); wAppIconPaint(icon); + wAppIconSave(icon); if (wPreferences.auto_arrange_icons) wArrangeIcons(dock->screen_ptr, True); @@ -2146,6 +2150,7 @@ Bool moveIconBetweenDocks(WDock * src, WDock * dest, WAppIcon * icon, int x, int icon->icon->shadowed = 0; icon->icon->force_paint = 1; } + wAppIconSave(icon); } if (src->auto_collapse || src->auto_raise_lower)