On Fri,  8 Oct 2010 at 15:08:34 -0400, Brad Jorsch wrote:
> 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 <[email protected]>




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

I am trying to understand why don't you simply kill the whole "let's look
in WMWindowAttributes if we ever saved a icon for this application in 
CachedPixmaps, and let's save it again if we did and the icon is no 
longer there" logic.

My WMWindowAttributes file was full of "Icon" lines for all 
applications I ever opened. But removing the icons from CachedPixmaps/
would make them re-appear even after your patches.

IOW, we should not care anymore about reading WMWindowAttributes from 
wApplicationCreate() and re-creating icons in CachedPixmaps/ based
on that. We should save the icon only when we dock an app. 

Perhaps I am missing something with this patch. But I think the diff
below could be added on top of your series. I just tested it and
I couldn't detect any bad effects (and no icon was saved in
CachedPixmap even if there was an old "Icon=" line in
WMWindowAttributes). What do you think?

Another thing. On wAppIconSave() you save the icon only if
the app is docked. But what prevents wmaker from saving
a new icon (rewriting the old) every time you open an
already-docked application?

diff --git a/src/application.c b/src/application.c
index fad9186..d35f976 100644
--- a/src/application.c
+++ b/src/application.c
@@ -347,29 +347,6 @@ WApplication *wApplicationCreate(WWindow * wwin)
                wArrangeIcons(scr, True);
        }
 
-       if (wapp->app_icon) {
-               char *tmp, *path;
-               struct stat dummy;
-
-               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;
 }
 





-- 
To unsubscribe, send mail to [email protected].

Reply via email to