diff --git a/src/appicon.c b/src/appicon.c index cd0e4ad2..4c966433 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "WindowMaker.h" #include "window.h" @@ -759,3 +761,33 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event) } } } + +void save_app_icon(WWindow *wwin, WApplication *wapp) +{ + char *tmp, *path; + struct stat dummy; + WScreen *scr = NULL; + + if (!wapp->app_icon) + return; + + scr = wwin->screen_ptr; + tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True); + + /* If the icon was saved by us from the client supplied icon, but is + * missing, recreate it. */ + if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL && + stat(tmp, &dummy) != 0 && errno == ENOENT) { + wmessage(_("recreating missing icon '%s'"), tmp); + path = wIconStore(wapp->app_icon->icon); + if (path) + wfree(path); + + wIconUpdate(wapp->app_icon->icon); + wAppIconPaint(wapp->app_icon); + } + + /* if the displayed icon was supplied by the client, save the icon */ + if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL) + wAppIconSave(wapp->app_icon); +} diff --git a/src/appicon.h b/src/appicon.h index c8a96dcc..fab712a1 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -76,6 +76,7 @@ WAppIcon * wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, void wAppIconDestroy(WAppIcon *aicon); void wAppIconPaint(WAppIcon *aicon); void wAppIconMove(WAppIcon *aicon, int x, int y); +void save_app_icon(WWindow *wwin, WApplication *wapp); Bool wAppIconChangeImage(WAppIcon *icon, char *file); Bool wAppIconSave(WAppIcon *aicon); #endif diff --git a/src/application.c b/src/application.c index ecc77ca0..31165143 100644 --- a/src/application.c +++ b/src/application.c @@ -22,13 +22,8 @@ #include -#include #include - -#include -#include #include -#include #include "WindowMaker.h" #include "menu.h" @@ -36,15 +31,12 @@ #ifdef USER_MENU #include "usermenu.h" #endif /* USER_MENU */ -#include "icon.h" #include "appicon.h" #include "application.h" #include "appmenu.h" #include "properties.h" -#include "funcs.h" #include "stacking.h" #include "actions.h" -#include "defaults.h" #include "workspace.h" #include "dock.h" @@ -349,29 +341,9 @@ WApplication *wApplicationCreate(WWindow * wwin) if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted) wArrangeIcons(scr, True); - if (wapp->app_icon) { - char *tmp, *path; - struct stat dummy; + /* Save the app_icon in a file */ + save_app_icon(wwin, wapp); - tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True); - - /* If the icon was saved by us from the client supplied icon, but is - * missing, recreate it. */ - if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL && - stat(tmp, &dummy) != 0 && errno == ENOENT) { - wmessage(_("recreating missing icon '%s'"), tmp); - path = wIconStore(wapp->app_icon->icon); - if (path) { - wfree(path); - } - wIconUpdate(wapp->app_icon->icon); - wAppIconPaint(wapp->app_icon); - } - - /* if the displayed icon was supplied by the client, save the icon */ - if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL) - wAppIconSave(wapp->app_icon); - } return wapp; }