>From dd44db57014ecc58a756b68fb1c24a9ee8ad35e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 19:17:35 +0200
Subject: [PATCH 09/13] wIconCreateWithIconFile() removed

The function wIconCreateWithIconFile() is joined to wIconCreate() and
is removed. Both functions had the same inteface and the same contents.

The only difference is that wIconCreateWithIconFile() is used for docks,
and therefore is not associated to any window, while wIconCreate() is used
with normal windows, and then wwin has window associated.

Then, we can use wwin to select the window options.
---
 src/appicon.c |    2 +-
 src/icon.c    |   74 ++++++++++++++++++++-------------------------------------
 src/icon.h    |    2 --
 3 files changed, 27 insertions(+), 51 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index ebe0160..0f318ed 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -126,7 +126,7 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char 
*command, char *wm_instance,
        if (wm_instance)
                dicon->wm_instance = wstrdup(wm_instance);
 
-       dicon->icon = wIconCreateWithIconFile(NULL, scr, NULL, wm_instance, 
wm_class, tile);
+       dicon->icon = wIconCreate(NULL, scr, NULL, wm_instance, wm_class, tile);
 
 #ifdef XDND
        wXDNDMakeAwareness(dicon->icon->core->window);
diff --git a/src/icon.c b/src/icon.c
index 351bd8a..6685a77 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -106,61 +106,37 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char 
*command,
        WIcon *icon;
        char *file = NULL;
 
-       icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y);
-
-       icon->owner = wwin;
-       if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) {
-               if (wwin->client_win == wwin->main_window) {
-                       WApplication *wapp;
-                       /* do not let miniwindow steal app-icon's icon window */
-                       wapp = wApplicationOf(wwin->client_win);
-                       if (!wapp || wapp->app_icon == NULL)
+       /* If we have wwindow, is a normal application, else is a dock */
+       if (wwin) {
+               icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y);
+
+               icon->owner = wwin;
+               if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) 
{
+                       if (wwin->client_win == wwin->main_window) {
+                               WApplication *wapp;
+                               /* do not let miniwindow steal app-icon's icon 
window */
+                               wapp = wApplicationOf(wwin->client_win);
+                               if (!wapp || wapp->app_icon == NULL)
+                                       icon->icon_win = 
wwin->wm_hints->icon_window;
+                       } else {
                                icon->icon_win = wwin->wm_hints->icon_window;
-               } else {
-                       icon->icon_win = wwin->wm_hints->icon_window;
+                       }
                }
-       }
 #ifdef NO_MINIWINDOW_TITLES
-       icon->show_title = 0;
+               icon->show_title = 0;
 #else
-       icon->show_title = 1;
+               icon->show_title = 1;
 #endif
-       /* Get the file name */
-       file = get_default_icon_filename(scr, instance, class, command, False);
-       if (file)
-               icon->file = wstrdup(file);
-
-       /* Load the icon using the file name */
-       icon->file_image = get_default_icon_rimage(scr, file, 
wPreferences.icon_size);
-       if (file)
-               wfree(file);
 
        /* Set the icon name */
-       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_type;
-
-       wIconUpdate(icon);
-
-       XFlush(dpy);
-
-       WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
-       WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
-
-       return icon;
-}
-
-WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
-                              char *instance, char *class, int tile_type)
-{
-       WIcon *icon;
-       char *file = NULL;
-
-       icon = wIconCreateCore(scr, 0, 0);
+               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);
+       } else {
+               icon = wIconCreateCore(scr, 0, 0);
+       }
 
        /* Get the file name */
        file = get_default_icon_filename(scr, instance, class, command, False);
@@ -176,6 +152,8 @@ WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, 
char *command,
 
        wIconUpdate(icon);
 
+       XFlush(dpy);
+
        WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
        WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
 
diff --git a/src/icon.h b/src/icon.h
index a888395..e0fb0e4 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,8 +54,6 @@ typedef struct WIcon {
                                         * color */
 } WIcon;
 
-WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
-                              char *instance, char *class, int tile_type);
 WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
                   char *instance, char *class, int tile_type);
 
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From dd44db57014ecc58a756b68fb1c24a9ee8ad35e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 19:17:35 +0200
Subject: [PATCH 09/13] wIconCreateWithIconFile() removed

The function wIconCreateWithIconFile() is joined to wIconCreate() and
is removed. Both functions had the same inteface and the same contents.

The only difference is that wIconCreateWithIconFile() is used for docks,
and therefore is not associated to any window, while wIconCreate() is used
with normal windows, and then wwin has window associated.

Then, we can use wwin to select the window options.
---
 src/appicon.c |    2 +-
 src/icon.c    |   74 ++++++++++++++++++++-------------------------------------
 src/icon.h    |    2 --
 3 files changed, 27 insertions(+), 51 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index ebe0160..0f318ed 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -126,7 +126,7 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance,
 	if (wm_instance)
 		dicon->wm_instance = wstrdup(wm_instance);
 
-	dicon->icon = wIconCreateWithIconFile(NULL, scr, NULL, wm_instance, wm_class, tile);
+	dicon->icon = wIconCreate(NULL, scr, NULL, wm_instance, wm_class, tile);
 
 #ifdef XDND
 	wXDNDMakeAwareness(dicon->icon->core->window);
diff --git a/src/icon.c b/src/icon.c
index 351bd8a..6685a77 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -106,61 +106,37 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
 	WIcon *icon;
 	char *file = NULL;
 
-	icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y);
-
-	icon->owner = wwin;
-	if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) {
-		if (wwin->client_win == wwin->main_window) {
-			WApplication *wapp;
-			/* do not let miniwindow steal app-icon's icon window */
-			wapp = wApplicationOf(wwin->client_win);
-			if (!wapp || wapp->app_icon == NULL)
+	/* If we have wwindow, is a normal application, else is a dock */
+	if (wwin) {
+		icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y);
+
+		icon->owner = wwin;
+		if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) {
+			if (wwin->client_win == wwin->main_window) {
+				WApplication *wapp;
+				/* do not let miniwindow steal app-icon's icon window */
+				wapp = wApplicationOf(wwin->client_win);
+				if (!wapp || wapp->app_icon == NULL)
+					icon->icon_win = wwin->wm_hints->icon_window;
+			} else {
 				icon->icon_win = wwin->wm_hints->icon_window;
-		} else {
-			icon->icon_win = wwin->wm_hints->icon_window;
+			}
 		}
-	}
 #ifdef NO_MINIWINDOW_TITLES
-	icon->show_title = 0;
+		icon->show_title = 0;
 #else
-	icon->show_title = 1;
+		icon->show_title = 1;
 #endif
-	/* Get the file name */
-	file = get_default_icon_filename(scr, instance, class, command, False);
-	if (file)
-		icon->file = wstrdup(file);
-
-	/* Load the icon using the file name */
-	icon->file_image = get_default_icon_rimage(scr, file, wPreferences.icon_size);
-	if (file)
-		wfree(file);
 
 	/* Set the icon name */
-	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_type;
-
-	wIconUpdate(icon);
-
-	XFlush(dpy);
-
-	WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
-	WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
-
-	return icon;
-}
-
-WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
-			       char *instance, char *class, int tile_type)
-{
-	WIcon *icon;
-	char *file = NULL;
-
-	icon = wIconCreateCore(scr, 0, 0);
+		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);
+	} else {
+		icon = wIconCreateCore(scr, 0, 0);
+	}
 
 	/* Get the file name */
 	file = get_default_icon_filename(scr, instance, class, command, False);
@@ -176,6 +152,8 @@ WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
 
 	wIconUpdate(icon);
 
+	XFlush(dpy);
+
 	WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
 	WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
 
diff --git a/src/icon.h b/src/icon.h
index a888395..e0fb0e4 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,8 +54,6 @@ typedef struct WIcon {
 					 * color */
 } WIcon;
 
-WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
-			       char *instance, char *class, int tile_type);
 WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
 		   char *instance, char *class, int tile_type);
 
-- 
1.7.10

Reply via email to