>From 90c59dd5b8f06af1e69116d6596e1e43b6609f32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 2 Oct 2012 23:22:10 +0200
Subject: [PATCH 9/9] icon_create_for_* same icon creation procedure
The contents for icon search wAppIconCreateForDock
where moved to icon_create_for_dock.
Now wAppIconCreateForDock and wAppIconCreate do the same work and
icon_create_for_dock and icon_create_for_wwindow do the same work too.
The procedure to create the icon is similar in both functions.
Now wAppIconCreateForDock, needs more arguments (command, instance and class).
---
src/appicon.c | 7 +------
src/icon.c | 28 +++++++++++++++++-----------
src/icon.h | 2 +-
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 45911b8..a90e35b 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char
*path, char *wm_instance
WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char
*wm_instance, char *wm_class, int tile)
{
WAppIcon *aicon;
- char *path;
aicon = wmalloc(sizeof(WAppIcon));
wretain(aicon);
@@ -127,12 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char
*command, char *wm_instance,
if (wm_instance)
aicon->wm_instance = wstrdup(wm_instance);
- /* Search the icon using instance and class, without default icon */
- path = get_default_icon_filename(scr, wm_instance, wm_class, command,
False);
+ aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class,
tile);
- aicon->icon = icon_create_for_dock(scr, path, tile);
- if (path)
- wfree(path);
#ifdef XDND
wXDNDMakeAwareness(aicon->icon->core->window);
#endif
diff --git a/src/icon.c b/src/icon.c
index 73592bc..e950a7d 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -127,38 +127,44 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
icon->show_title = 1;
#endif
+ icon->icon_name = wNETWMGetIconName(wwin->client_win);
+ if (icon->icon_name)
+ wwin->flags.net_has_icon_title = 1;
+ else
+ wGetIconName(dpy, wwin->client_win, &icon->icon_name);
+
/* Get the application icon, default included */
file = get_default_icon_filename(scr, wwin->wm_instance,
wwin->wm_class, NULL, True);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_default_icon_rimage(scr, icon->file,
wPreferences.icon_size);
+ wfree(file);
}
- icon->icon_name = wNETWMGetIconName(wwin->client_win);
- if (icon->icon_name)
- wwin->flags.net_has_icon_title = 1;
- else
- wGetIconName(dpy, wwin->client_win, &icon->icon_name);
-
icon->tile_type = TILE_NORMAL;
wIconUpdate(icon);
- XFlush(dpy);
-
WMAddNotificationObserver(appearanceObserver, icon,
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon,
WNIconTileSettingsChanged, icon);
+
return icon;
}
-WIcon *icon_create_for_dock(WScreen *scr, char *iconfile, int tile)
+WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance,
char *wm_class, int tile)
{
WIcon *icon;
+ char *file = NULL;
icon = icon_create_core(scr, 0, 0);
- icon->file_image = get_default_icon_rimage(scr, iconfile,
wPreferences.icon_size);
- icon->file = wstrdup(iconfile);
+ /* Search the icon using instance and class, without default icon */
+ file = get_default_icon_filename(scr, wm_instance, wm_class, command,
False);
+ if (file) {
+ icon->file = wstrdup(file);
+ icon->file_image = get_default_icon_rimage(scr, icon->file,
wPreferences.icon_size);
+ wfree(file);
+ }
icon->tile_type = tile;
diff --git a/src/icon.h b/src/icon.h
index 7de9e50..f0786cb 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,7 +54,7 @@ typedef struct WIcon {
* color */
} WIcon;
-WIcon *icon_create_for_dock(WScreen *scr, char *iconfile, int tile);
+WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance,
char *wm_class, int tile);
WIcon *icon_create_for_wwindow(WWindow *wwin);
void wIconDestroy(WIcon *icon);
--
1.7.10.4
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 90c59dd5b8f06af1e69116d6596e1e43b6609f32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 2 Oct 2012 23:22:10 +0200
Subject: [PATCH 9/9] icon_create_for_* same icon creation procedure
The contents for icon search wAppIconCreateForDock
where moved to icon_create_for_dock.
Now wAppIconCreateForDock and wAppIconCreate do the same work and
icon_create_for_dock and icon_create_for_wwindow do the same work too.
The procedure to create the icon is similar in both functions.
Now wAppIconCreateForDock, needs more arguments (command, instance and class).
---
src/appicon.c | 7 +------
src/icon.c | 28 +++++++++++++++++-----------
src/icon.h | 2 +-
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 45911b8..a90e35b 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance
WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
WAppIcon *aicon;
- char *path;
aicon = wmalloc(sizeof(WAppIcon));
wretain(aicon);
@@ -127,12 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
if (wm_instance)
aicon->wm_instance = wstrdup(wm_instance);
- /* Search the icon using instance and class, without default icon */
- path = get_default_icon_filename(scr, wm_instance, wm_class, command, False);
+ aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile);
- aicon->icon = icon_create_for_dock(scr, path, tile);
- if (path)
- wfree(path);
#ifdef XDND
wXDNDMakeAwareness(aicon->icon->core->window);
#endif
diff --git a/src/icon.c b/src/icon.c
index 73592bc..e950a7d 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -127,38 +127,44 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
icon->show_title = 1;
#endif
+ icon->icon_name = wNETWMGetIconName(wwin->client_win);
+ if (icon->icon_name)
+ wwin->flags.net_has_icon_title = 1;
+ else
+ wGetIconName(dpy, wwin->client_win, &icon->icon_name);
+
/* Get the application icon, default included */
file = get_default_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, True);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_default_icon_rimage(scr, icon->file, wPreferences.icon_size);
+ wfree(file);
}
- icon->icon_name = wNETWMGetIconName(wwin->client_win);
- if (icon->icon_name)
- wwin->flags.net_has_icon_title = 1;
- else
- wGetIconName(dpy, wwin->client_win, &icon->icon_name);
-
icon->tile_type = TILE_NORMAL;
wIconUpdate(icon);
- XFlush(dpy);
-
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
+
return icon;
}
-WIcon *icon_create_for_dock(WScreen *scr, char *iconfile, int tile)
+WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
WIcon *icon;
+ char *file = NULL;
icon = icon_create_core(scr, 0, 0);
- icon->file_image = get_default_icon_rimage(scr, iconfile, wPreferences.icon_size);
- icon->file = wstrdup(iconfile);
+ /* Search the icon using instance and class, without default icon */
+ file = get_default_icon_filename(scr, wm_instance, wm_class, command, False);
+ if (file) {
+ icon->file = wstrdup(file);
+ icon->file_image = get_default_icon_rimage(scr, icon->file, wPreferences.icon_size);
+ wfree(file);
+ }
icon->tile_type = tile;
diff --git a/src/icon.h b/src/icon.h
index 7de9e50..f0786cb 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,7 +54,7 @@ typedef struct WIcon {
* color */
} WIcon;
-WIcon *icon_create_for_dock(WScreen *scr, char *iconfile, int tile);
+WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile);
WIcon *icon_create_for_wwindow(WWindow *wwin);
void wIconDestroy(WIcon *icon);
--
1.7.10.4