1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

New functions in icon.c

This patch creates some functions:

1. Rename getnameforicon() to get_name_for_icon()
2. New function get_icon_cache_path, to get the icon cache folder
   ($HOME + GNUstep/Library/WindowMaker/CachedPixmaps). This folder
   is defined now in the preprocessor. Not used yet, in next commits.
3. New function get_wwindow_image_from_wmhints to read the image from
   X11 wmhints. Previous code at wIconStore() now changed.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-06-06 08:41:01 +02:00
committed by Carlos R. Mafra
parent c61e5bfeb8
commit 7ef416f8ac

View File

@@ -49,6 +49,7 @@
extern WPreferences wPreferences;
#define MOD_MASK wPreferences.modifier_mask
#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
extern Cursor wCursor[WCUR_LAST];
@@ -397,7 +398,7 @@ Bool wIconChangeImageFile(WIcon * icon, char *file)
return !error;
}
static char *getnameforicon(WWindow * wwin)
static char *get_name_for_icon(WWindow * wwin)
{
char *prefix, *suffix;
char *path;
@@ -450,6 +451,46 @@ static char *getnameforicon(WWindow * wwin)
return path;
}
static char *get_icon_cache_path(void)
{
char *prefix, *path;
int len, ret;
prefix = wusergnusteppath();
len = strlen(prefix) + strlen(CACHE_ICON_PATH) + 2;
path = wmalloc(len);
snprintf(path, len, "%s%s/", prefix, CACHE_ICON_PATH);
/* If the folder exists, exit */
if (access(path, F_OK) == 0)
return path;
/* Create the folder */
ret = wmkdirhier((const char *) path);
/* Exit 1 on success, 0 on failure */
if (ret == 1)
return path;
/* Fail */
wfree(path);
return NULL;
}
static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
{
RImage *image = NULL;
XWMHints *hints = wwin->wm_hints;
if (hints && (hints->flags & IconPixmapHint) && hints->icon_pixmap != None)
image = RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
hints->icon_pixmap,
(hints->flags & IconMaskHint)
? hints->icon_mask : None);
return image;
}
/*
* wIconStore--
* Stores the client supplied icon at ~/GNUstep/Library/WindowMaker/CachedPixmaps
@@ -468,7 +509,7 @@ char *wIconStore(WIcon * icon)
if (!wwin)
return NULL;
path = getnameforicon(wwin);
path = get_name_for_icon(wwin);
if (!path)
return NULL;
@@ -476,14 +517,10 @@ char *wIconStore(WIcon * icon)
if (access(path, F_OK) == 0)
return path;
if (wwin->net_icon_image) {
if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
} else if (wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)
&& wwin->wm_hints->icon_pixmap != None) {
image = RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
wwin->wm_hints->icon_pixmap, (wwin->wm_hints->flags & IconMaskHint)
? wwin->wm_hints->icon_mask : None);
}
else
image = get_wwindow_image_from_wmhints(wwin, icon);
if (!image) {
wfree(path);