>From 076c7a52213c4f88bdc67a590f8de0e1eeb5fc1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 14 Nov 2012 19:53:04 +0100
Subject: [PATCH 1/6] wIconUpdate image preselected
The function wIconUpdate can receive a image to setup as icon image.
If image is NULL, then use the original method, using different procedures
to get the image.
---
src/appicon.c | 6 +++---
src/client.c | 4 ++--
src/dock.c | 8 ++++----
src/icon.c | 46 +++++++++++++++++++++++++---------------------
src/icon.h | 2 +-
src/wmspec.c | 4 ++--
6 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index ac0c4ba..b02abbe 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -151,7 +151,7 @@ void makeAppIconFor(WApplication *wapp)
/* Create the icon */
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Now, paint the icon */
if (!WFLAGP(wapp->main_window_desc, no_appicon))
@@ -254,7 +254,7 @@ void removeAppIconFor(WApplication *wapp)
wapp->app_icon->icon->icon_win = None;
/* Update the icon images */
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Paint it */
wAppIconPaint(wapp->app_icon);
@@ -989,7 +989,7 @@ void create_appicon_from_dock(WWindow *wwin, WApplication
*wapp, Window main_win
wapp->app_icon->icon->icon_win =
mainw->wm_hints->icon_window;
/* Update the icon images */
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Paint it */
wAppIconPaint(wapp->app_icon);
diff --git a/src/client.c b/src/client.c
index 3287306..c11f306 100644
--- a/src/client.c
+++ b/src/client.c
@@ -473,11 +473,11 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent
* event)
WApplication *wapp;
if (wwin->flags.miniaturized && wwin->icon) {
- wIconUpdate(wwin->icon);
+ wIconUpdate(wwin->icon, NULL);
}
wapp = wApplicationOf(wwin->main_window);
if (wapp && wapp->app_icon) {
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
wAppIconPaint(wapp->app_icon);
}
}
diff --git a/src/dock.c b/src/dock.c
index d7d5c53..6e2e0e3 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -541,7 +541,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry
*entry)
aicon->icon->shadowed = 0;
/* Update the icon images */
- wIconUpdate(aicon->icon);
+ wIconUpdate(aicon->icon, NULL);
/* Paint it */
wAppIconPaint(aicon);
@@ -1938,7 +1938,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x,
int y, Bool update_icon
/* Update the icon images */
if (lupdate_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
@@ -2089,7 +2089,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest,
WAppIcon *icon, int x,
/* Update the icon images */
if (update_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
@@ -2166,7 +2166,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
/* Update the icon images */
if (update_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
diff --git a/src/icon.c b/src/icon.c
index 6a0e817..10f7b24 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -94,7 +94,7 @@ static void tileObserver(void *self, WMNotification *notif)
{
WIcon *icon = (WIcon *) self;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
XClearArea(dpy, icon->core->window, 0, 0, 1, 1, True);
}
@@ -152,7 +152,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
icon->tile_type = TILE_NORMAL;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
WMAddNotificationObserver(appearanceObserver, icon,
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon,
WNIconTileSettingsChanged, icon);
@@ -177,7 +177,7 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command,
char *wm_instance, char
icon->tile_type = tile;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
WMAddNotificationObserver(appearanceObserver, icon,
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon,
WNIconTileSettingsChanged, icon);
@@ -346,7 +346,7 @@ void wIconChangeTitle(WIcon *icon, char *new_title)
icon->icon_name = new_title;
if (changed)
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
else
wIconPaint(icon);
}
@@ -400,7 +400,7 @@ Bool wIconChangeImageFile(WIcon *icon, char *file)
/* Set the new image */
icon->file_image = image;
icon->file = wstrdup(path);
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
} else {
error = 1;
}
@@ -599,26 +599,30 @@ static void unset_icon_image(WIcon *icon)
}
}
-void wIconUpdate(WIcon *icon)
+void wIconUpdate(WIcon *icon, RImage *image)
{
WWindow *wwin = icon->owner;
- if (wwin && WFLAGP(wwin, always_user_icon)) {
- /* Forced use user_icon */
- get_rimage_icon_from_user_icon(icon);
- } else if (icon->icon_win != None) {
- /* Get the Pixmap from the WIcon */
- get_rimage_icon_from_icon_win(icon);
- } else if (wwin && wwin->net_icon_image) {
- /* Use _NET_WM_ICON icon */
- get_rimage_icon_from_x11(icon);
- } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags &
IconPixmapHint)) {
- /* Get the Pixmap from the wm_hints, else, from the user */
- if (get_rimage_icon_from_wm_hints(icon))
- get_rimage_icon_from_user_icon(icon);
+ if (image) {
+ icon->file_image = image;
} else {
- /* Get the Pixmap from the user */
- get_rimage_icon_from_user_icon(icon);
+ if (wwin && WFLAGP(wwin, always_user_icon)) {
+ /* Forced use user_icon */
+ get_rimage_icon_from_user_icon(icon);
+ } else if (icon->icon_win != None) {
+ /* Get the Pixmap from the WIcon */
+ get_rimage_icon_from_icon_win(icon);
+ } else if (wwin && wwin->net_icon_image) {
+ /* Use _NET_WM_ICON icon */
+ get_rimage_icon_from_x11(icon);
+ } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags &
IconPixmapHint)) {
+ /* Get the Pixmap from the wm_hints, else, from the
user */
+ if (get_rimage_icon_from_wm_hints(icon))
+ get_rimage_icon_from_user_icon(icon);
+ } else {
+ /* Get the Pixmap from the user */
+ get_rimage_icon_from_user_icon(icon);
+ }
}
update_icon_pixmap(icon);
diff --git a/src/icon.h b/src/icon.h
index dfa30bc..a3f538b 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -58,7 +58,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin);
void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
-void wIconUpdate(WIcon *icon);
+void wIconUpdate(WIcon *icon, RImage *image);
void wIconSelect(WIcon *icon);
void wIconChangeTitle(WIcon *icon, char *new_title);
void update_icon_pixmap(WIcon *icon);
diff --git a/src/wmspec.c b/src/wmspec.c
index b3dfb8b..c758f0a 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -468,12 +468,12 @@ static void updateIconImage(WWindow *wwin)
/* Refresh the Window Icon */
if (wwin->icon)
- wIconUpdate(wwin->icon);
+ wIconUpdate(wwin->icon, NULL);
/* Refresh the application icon */
WApplication *app = wApplicationOf(wwin->main_window);
if (app && app->app_icon) {
- wIconUpdate(app->app_icon->icon);
+ wIconUpdate(app->app_icon->icon, NULL);
wAppIconPaint(app->app_icon);
}
}
--
1.7.10.4
>From 076c7a52213c4f88bdc67a590f8de0e1eeb5fc1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 14 Nov 2012 19:53:04 +0100
Subject: [PATCH 1/6] wIconUpdate image preselected
The function wIconUpdate can receive a image to setup as icon image.
If image is NULL, then use the original method, using different procedures
to get the image.
---
src/appicon.c | 6 +++---
src/client.c | 4 ++--
src/dock.c | 8 ++++----
src/icon.c | 46 +++++++++++++++++++++++++---------------------
src/icon.h | 2 +-
src/wmspec.c | 4 ++--
6 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index ac0c4ba..b02abbe 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -151,7 +151,7 @@ void makeAppIconFor(WApplication *wapp)
/* Create the icon */
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Now, paint the icon */
if (!WFLAGP(wapp->main_window_desc, no_appicon))
@@ -254,7 +254,7 @@ void removeAppIconFor(WApplication *wapp)
wapp->app_icon->icon->icon_win = None;
/* Update the icon images */
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Paint it */
wAppIconPaint(wapp->app_icon);
@@ -989,7 +989,7 @@ void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_win
wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;
/* Update the icon images */
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
/* Paint it */
wAppIconPaint(wapp->app_icon);
diff --git a/src/client.c b/src/client.c
index 3287306..c11f306 100644
--- a/src/client.c
+++ b/src/client.c
@@ -473,11 +473,11 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
WApplication *wapp;
if (wwin->flags.miniaturized && wwin->icon) {
- wIconUpdate(wwin->icon);
+ wIconUpdate(wwin->icon, NULL);
}
wapp = wApplicationOf(wwin->main_window);
if (wapp && wapp->app_icon) {
- wIconUpdate(wapp->app_icon->icon);
+ wIconUpdate(wapp->app_icon->icon, NULL);
wAppIconPaint(wapp->app_icon);
}
}
diff --git a/src/dock.c b/src/dock.c
index d7d5c53..6e2e0e3 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -541,7 +541,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry)
aicon->icon->shadowed = 0;
/* Update the icon images */
- wIconUpdate(aicon->icon);
+ wIconUpdate(aicon->icon, NULL);
/* Paint it */
wAppIconPaint(aicon);
@@ -1938,7 +1938,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon
/* Update the icon images */
if (lupdate_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
@@ -2089,7 +2089,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
/* Update the icon images */
if (update_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
@@ -2166,7 +2166,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
/* Update the icon images */
if (update_icon)
- wIconUpdate(icon->icon);
+ wIconUpdate(icon->icon, NULL);
/* Paint it */
wAppIconPaint(icon);
diff --git a/src/icon.c b/src/icon.c
index 6a0e817..10f7b24 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -94,7 +94,7 @@ static void tileObserver(void *self, WMNotification *notif)
{
WIcon *icon = (WIcon *) self;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
XClearArea(dpy, icon->core->window, 0, 0, 1, 1, True);
}
@@ -152,7 +152,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
icon->tile_type = TILE_NORMAL;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
@@ -177,7 +177,7 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char
icon->tile_type = tile;
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
@@ -346,7 +346,7 @@ void wIconChangeTitle(WIcon *icon, char *new_title)
icon->icon_name = new_title;
if (changed)
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
else
wIconPaint(icon);
}
@@ -400,7 +400,7 @@ Bool wIconChangeImageFile(WIcon *icon, char *file)
/* Set the new image */
icon->file_image = image;
icon->file = wstrdup(path);
- wIconUpdate(icon);
+ wIconUpdate(icon, NULL);
} else {
error = 1;
}
@@ -599,26 +599,30 @@ static void unset_icon_image(WIcon *icon)
}
}
-void wIconUpdate(WIcon *icon)
+void wIconUpdate(WIcon *icon, RImage *image)
{
WWindow *wwin = icon->owner;
- if (wwin && WFLAGP(wwin, always_user_icon)) {
- /* Forced use user_icon */
- get_rimage_icon_from_user_icon(icon);
- } else if (icon->icon_win != None) {
- /* Get the Pixmap from the WIcon */
- get_rimage_icon_from_icon_win(icon);
- } else if (wwin && wwin->net_icon_image) {
- /* Use _NET_WM_ICON icon */
- get_rimage_icon_from_x11(icon);
- } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) {
- /* Get the Pixmap from the wm_hints, else, from the user */
- if (get_rimage_icon_from_wm_hints(icon))
- get_rimage_icon_from_user_icon(icon);
+ if (image) {
+ icon->file_image = image;
} else {
- /* Get the Pixmap from the user */
- get_rimage_icon_from_user_icon(icon);
+ if (wwin && WFLAGP(wwin, always_user_icon)) {
+ /* Forced use user_icon */
+ get_rimage_icon_from_user_icon(icon);
+ } else if (icon->icon_win != None) {
+ /* Get the Pixmap from the WIcon */
+ get_rimage_icon_from_icon_win(icon);
+ } else if (wwin && wwin->net_icon_image) {
+ /* Use _NET_WM_ICON icon */
+ get_rimage_icon_from_x11(icon);
+ } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) {
+ /* Get the Pixmap from the wm_hints, else, from the user */
+ if (get_rimage_icon_from_wm_hints(icon))
+ get_rimage_icon_from_user_icon(icon);
+ } else {
+ /* Get the Pixmap from the user */
+ get_rimage_icon_from_user_icon(icon);
+ }
}
update_icon_pixmap(icon);
diff --git a/src/icon.h b/src/icon.h
index dfa30bc..a3f538b 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -58,7 +58,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin);
void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
-void wIconUpdate(WIcon *icon);
+void wIconUpdate(WIcon *icon, RImage *image);
void wIconSelect(WIcon *icon);
void wIconChangeTitle(WIcon *icon, char *new_title);
void update_icon_pixmap(WIcon *icon);
diff --git a/src/wmspec.c b/src/wmspec.c
index b3dfb8b..c758f0a 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -468,12 +468,12 @@ static void updateIconImage(WWindow *wwin)
/* Refresh the Window Icon */
if (wwin->icon)
- wIconUpdate(wwin->icon);
+ wIconUpdate(wwin->icon, NULL);
/* Refresh the application icon */
WApplication *app = wApplicationOf(wwin->main_window);
if (app && app->app_icon) {
- wIconUpdate(app->app_icon->icon);
+ wIconUpdate(app->app_icon->icon, NULL);
wAppIconPaint(app->app_icon);
}
}
--
1.7.10.4