>From 102018a484692802141b38bdbdb8ab46debcd9f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 08:41:01 +0200
Subject: [PATCH 03/10] 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.
---
src/icon.c | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 2a6d774..57e1cfe 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -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,41 @@ 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) + 1;
+ path = wmalloc(len);
+ snprintf(path, len, "%s%s", prefix, CACHE_ICON_PATH);
+
+ ret = create_path(path);
+
+ if (ret == 0)
+ return path;
+
+ /* Fail */
+ wfree(path);
+ return NULL;
+}
+
+static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
+{
+ RImage *image;
+
+ 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);
+ }
+ return image;
+}
+
/*
* wIconStore--
* Stores the client supplied icon at
~/GNUstep/Library/WindowMaker/CachedPixmaps
@@ -468,7 +504,7 @@ char *wIconStore(WIcon * icon)
if (!wwin)
return NULL;
- path = getnameforicon(wwin);
+ path = get_name_for_icon(wwin);
if (!path)
return NULL;
@@ -476,14 +512,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);
--
1.7.10
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 102018a484692802141b38bdbdb8ab46debcd9f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 08:41:01 +0200
Subject: [PATCH 03/10] 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.
---
src/icon.c | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 2a6d774..57e1cfe 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -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,41 @@ 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) + 1;
+ path = wmalloc(len);
+ snprintf(path, len, "%s%s", prefix, CACHE_ICON_PATH);
+
+ ret = create_path(path);
+
+ if (ret == 0)
+ return path;
+
+ /* Fail */
+ wfree(path);
+ return NULL;
+}
+
+static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
+{
+ RImage *image;
+
+ 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);
+ }
+ return image;
+}
+
/*
* wIconStore--
* Stores the client supplied icon at ~/GNUstep/Library/WindowMaker/CachedPixmaps
@@ -468,7 +504,7 @@ char *wIconStore(WIcon * icon)
if (!wwin)
return NULL;
- path = getnameforicon(wwin);
+ path = get_name_for_icon(wwin);
if (!path)
return NULL;
@@ -476,14 +512,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);
--
1.7.10