1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

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 <anomie@users.sourceforge.net>
This commit is contained in:
Brad Jorsch
2010-10-08 15:08:34 -04:00
committed by Carlos R. Mafra
parent 125cba8f82
commit a396f3bd66
5 changed files with 32 additions and 20 deletions

View File

@@ -30,6 +30,7 @@
#include "WindowMaker.h" #include "WindowMaker.h"
#include "window.h" #include "window.h"
#include "icon.h" #include "icon.h"
#include "application.h"
#include "appicon.h" #include "appicon.h"
#include "actions.h" #include "actions.h"
#include "stacking.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)) #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
static void hideCallback(WMenu * menu, WMenuEntry * entry) static void hideCallback(WMenu * menu, WMenuEntry * entry)

View File

@@ -95,5 +95,7 @@ Bool wAppIconChangeImage(WAppIcon *icon, char *file);
void wAppIconMove(WAppIcon *aicon, int x, int y); void wAppIconMove(WAppIcon *aicon, int x, int y);
Bool wAppIconSave(WAppIcon *aicon);
#endif #endif

View File

@@ -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 *dict = WDWindowAttributes->dictionary;
WMPropList *adict, *key, *iconk; WMPropList *adict, *key, *iconk;
@@ -202,27 +202,12 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance
} }
if (iconPath) { if (iconPath) {
saveIconNameFor(iconPath, wm_instance, wm_class); wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class);
wfree(iconPath); 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) WApplication *wApplicationCreate(WWindow * wwin)
{ {
WScreen *scr = wwin->screen_ptr; WScreen *scr = wwin->screen_ptr;
@@ -324,6 +309,7 @@ WApplication *wApplicationCreate(WWindow * wwin)
if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint)) if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint))
wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon);
wAppIconSave(wapp->app_icon);
} else { } else {
wapp->app_icon = wAppIconCreate(wapp->main_window_desc); 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 the displayed icon was supplied by the client, save the icon */
if (!tmp) if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
extractClientIcon(wapp->app_icon); wAppIconSave(wapp->app_icon);
} }
return wapp; return wapp;
} }

View File

@@ -58,6 +58,8 @@ WApplication *wApplicationOf(Window window);
void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance,
char *wm_class); char *wm_class);
void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance,
char *wm_class);
void wAppBounce(WApplication *); void wAppBounce(WApplication *);
void wAppBounceWhileUrgent(WApplication *); void wAppBounceWhileUrgent(WApplication *);

View File

@@ -575,6 +575,7 @@ static void keepIconsCallback(WMenu * menu, WMenuEntry * entry)
wAppIconPaint(aicon); wAppIconPaint(aicon);
} }
} }
wAppIconSave(aicon);
} }
WMFreeArray(selectedIcons); WMFreeArray(selectedIcons);
} }
@@ -1207,8 +1208,10 @@ static void dockIconPaint(WAppIcon * btn)
{ {
if (btn == btn->icon->core->screen_ptr->clip_icon) if (btn == btn->icon->core->screen_ptr->clip_icon)
wClipIconPaint(btn); wClipIconPaint(btn);
else else {
wAppIconPaint(btn); wAppIconPaint(btn);
wAppIconSave(btn);
}
} }
static WMPropList *make_icon_state(WAppIcon * 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); MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core);
wAppIconMove(icon, icon->x_pos, icon->y_pos); wAppIconMove(icon, icon->x_pos, icon->y_pos);
wAppIconPaint(icon); wAppIconPaint(icon);
wAppIconSave(icon);
if (wPreferences.auto_arrange_icons) if (wPreferences.auto_arrange_icons)
wArrangeIcons(dock->screen_ptr, True); 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->shadowed = 0;
icon->icon->force_paint = 1; icon->icon->force_paint = 1;
} }
wAppIconSave(icon);
} }
if (src->auto_collapse || src->auto_raise_lower) if (src->auto_collapse || src->auto_raise_lower)