mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +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:
committed by
Carlos R. Mafra
parent
125cba8f82
commit
a396f3bd66
@@ -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)
|
||||
|
||||
@@ -95,5 +95,7 @@ Bool wAppIconChangeImage(WAppIcon *icon, char *file);
|
||||
|
||||
void wAppIconMove(WAppIcon *aicon, int x, int y);
|
||||
|
||||
Bool wAppIconSave(WAppIcon *aicon);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user