>From 60c94327eede7004e5b9a2a772402afbd4fbb660 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 Jul 2012 20:59:00 +0200
Subject: [PATCH 12/13] wAppIconCreateForDock removed

The function wAppIconCreateForDock() is now removed. Their code is duplicated
with wAppIconCreate(), so can be changed.

The different part is that wAppIconCreate() uses the wwin argument, because
is used for normal windows, rather than wAppIconCreateForDock() used for
docks and without window associated. Then, the different parts uses wwin for
the different code.
---
 src/appicon.c |   96 ++++++++++++++++++++++-----------------------------------
 src/appicon.h |    3 +-
 src/dock.c    |    8 ++---
 3 files changed, 41 insertions(+), 66 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 72ef62f..ea9cd9b 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -67,7 +67,6 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event);
 static void iconDblClick(WObjDescriptor * desc, XEvent * event);
 static void iconExpose(WObjDescriptor * desc, XEvent * event);
 static void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, 
char *wm_class);
-static WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, 
char *wm_instance, char *wm_class, int tile);
 static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon);
 static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon);
 
@@ -106,43 +105,59 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char 
*path, char *wm_instance
        }
 }
 
-WAppIcon *wAppIconCreateForDock(WWindow *wwin, WScreen *scr, char *command, 
char *wm_instance, char *wm_class, int tile)
+WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char 
*wm_instance, char *wm_class, int tile)
 {
-       WAppIcon *dicon;
+       WAppIcon *aicon;
 
-       dicon = wmalloc(sizeof(WAppIcon));
-       wretain(dicon);
-       dicon->yindex = -1;
-       dicon->xindex = -1;
+       aicon = wmalloc(sizeof(WAppIcon));
+       wretain(aicon);
+
+       aicon->yindex = -1;
+       aicon->xindex = -1;
 
-       add_to_appicon_list(scr, dicon);
+       /* If wwin exists, then creating app for window,
+        * else, creating icon for dock */
+       if (wwin) {
+               /* When no_appicon is set we want to avoid having it on the list
+                * because otherwise there will be a hole when the icons are
+                * arranged with wArrangeIcons() */
+               if (!WFLAGP(wwin, no_appicon))
+                       add_to_appicon_list(scr, aicon);
+       } else {
+               add_to_appicon_list(scr, aicon);
+       }
 
        if (command)
-               dicon->command = wstrdup(command);
+               aicon->command = wstrdup(command);
 
        if (wm_class)
-               dicon->wm_class = wstrdup(wm_class);
+               aicon->wm_class = wstrdup(wm_class);
 
        if (wm_instance)
-               dicon->wm_instance = wstrdup(wm_instance);
+               aicon->wm_instance = wstrdup(wm_instance);
 
-       dicon->icon = wIconCreate(NULL, scr, NULL, wm_instance, wm_class, tile);
+       aicon->icon = wIconCreate(wwin, scr, NULL, wm_instance, wm_class, tile);
 
 #ifdef XDND
-       wXDNDMakeAwareness(dicon->icon->core->window);
+       wXDNDMakeAwareness(aicon->icon->core->window);
 #endif
 
-       /* will be overriden by dock */
-       dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
-       dicon->icon->core->descriptor.handle_expose = iconExpose;
-       dicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
-       dicon->icon->core->descriptor.parent = dicon;
-       AddToStackList(dicon->icon->core);
+       /* will be overriden if docked */
+       aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
+       aicon->icon->core->descriptor.handle_expose = iconExpose;
+       aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
+       aicon->icon->core->descriptor.parent = aicon;
+       AddToStackList(aicon->icon->core);
+
+       if (wwin)
+               aicon->icon->show_title = 0;
+
+       wIconUpdate(aicon->icon);
 
-       return dicon;
+       return aicon;
 }
 
-void makeAppIconFor(WApplication * wapp)
+void makeAppIconFor(WApplication *wapp)
 {
        WWindow *wwin = wapp->main_window_desc;
 
@@ -224,45 +239,6 @@ void removeAppIconFor(WApplication * wapp)
                wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
 }
 
-WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char 
*wm_instance, char *wm_class, int tile)
-{
-       WAppIcon *aicon;
-
-       aicon = wmalloc(sizeof(WAppIcon));
-       wretain(aicon);
-
-       aicon->yindex = -1;
-       aicon->xindex = -1;
-
-       /* When no_appicon is set we want to avoid having it on the list
-        * because otherwise there will be a hole when the icons are
-        * arranged with wArrangeIcons() */
-       if (!WFLAGP(wwin, no_appicon))
-               add_to_appicon_list(scr, aicon);
-
-       if (wm_class)
-               aicon->wm_class = wstrdup(wm_class);
-
-       if (wm_instance)
-               aicon->wm_instance = wstrdup(wm_instance);
-
-       aicon->icon = wIconCreate(wwin, scr, NULL, wm_instance, wm_class, 
TILE_NORMAL);
-#ifdef XDND
-       wXDNDMakeAwareness(aicon->icon->core->window);
-#endif
-
-       /* will be overriden if docked */
-       aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
-       aicon->icon->core->descriptor.handle_expose = iconExpose;
-       aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
-       aicon->icon->core->descriptor.parent = aicon;
-       AddToStackList(aicon->icon->core);
-       aicon->icon->show_title = 0;
-       wIconUpdate(aicon->icon);
-
-       return aicon;
-}
-
 void wAppIconDestroy(WAppIcon * aicon)
 {
        WScreen *scr = aicon->icon->core->screen_ptr;
diff --git a/src/appicon.h b/src/appicon.h
index 63dc798..8e13f1c 100644
--- a/src/appicon.h
+++ b/src/appicon.h
@@ -69,8 +69,7 @@ typedef struct WAppIcon {
        unsigned int lock:1;             /* do not allow to be destroyed */
 } WAppIcon;
 
-WAppIcon *wAppIconCreateForDock(WWindow *wwin, WScreen *scr, char *command,
-                               char *wm_instance, char *wm_class, int tile);
+WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char 
*wm_instance, char *wm_class, int tile);
 
 void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window);
 void wAppIconDestroy(WAppIcon *aicon);
diff --git a/src/dock.c b/src/dock.c
index a641723..c90d1f5 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -730,14 +730,14 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type)
        if (type == WM_CLIP) {
                if (scr->clip_icon)
                        return scr->clip_icon;
-               btn = wAppIconCreateForDock(NULL, scr, NULL, "Logo", "WMClip", 
TILE_CLIP);
+               btn = wAppIconCreate(NULL, scr, NULL, "Logo", "WMClip", 
TILE_CLIP);
                btn->icon->core->descriptor.handle_expose = clipIconExpose;
                btn->icon->core->descriptor.handle_enternotify = 
clipEnterNotify;
                btn->icon->core->descriptor.handle_leavenotify = 
clipLeaveNotify;
                /*x_pos = scr->scr_width - ICON_SIZE*2 - DOCK_EXTRA_SPACE; */
                x_pos = 0;
        } else {
-               btn = wAppIconCreateForDock(NULL, scr, NULL, "Logo", "WMDock", 
TILE_NORMAL);
+               btn = wAppIconCreate(NULL, scr, NULL, "Logo", "WMDock", 
TILE_NORMAL);
                x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE;
        }
 
@@ -1391,7 +1391,7 @@ static WAppIcon *restore_icon_state(WScreen *scr, 
WMPropList *info, int type, in
                        return NULL;
                }
 
-               aicon = wAppIconCreateForDock(NULL, scr, command, winstance, 
wclass, TILE_NORMAL);
+               aicon = wAppIconCreate(NULL, scr, command, winstance, wclass, 
TILE_NORMAL);
                if (wclass)
                        wfree(wclass);
                if (winstance)
@@ -2903,7 +2903,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window)
                                icon->launching = 1;
                                dockIconPaint(icon);
 
-                               aicon = wAppIconCreateForDock(NULL, 
dock->screen_ptr, NULL,
+                               aicon = wAppIconCreate(NULL, dock->screen_ptr, 
NULL,
                                                              wm_instance, 
wm_class, TILE_NORMAL);
                                /* XXX: can: aicon->icon == NULL ? */
                                PlaceIcon(dock->screen_ptr, &x0, &y0, 
wGetHeadForWindow(aicon->icon->owner));
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 60c94327eede7004e5b9a2a772402afbd4fbb660 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 Jul 2012 20:59:00 +0200
Subject: [PATCH 12/13] wAppIconCreateForDock removed

The function wAppIconCreateForDock() is now removed. Their code is duplicated
with wAppIconCreate(), so can be changed.

The different part is that wAppIconCreate() uses the wwin argument, because
is used for normal windows, rather than wAppIconCreateForDock() used for
docks and without window associated. Then, the different parts uses wwin for
the different code.
---
 src/appicon.c |   96 ++++++++++++++++++++++-----------------------------------
 src/appicon.h |    3 +-
 src/dock.c    |    8 ++---
 3 files changed, 41 insertions(+), 66 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 72ef62f..ea9cd9b 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -67,7 +67,6 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event);
 static void iconDblClick(WObjDescriptor * desc, XEvent * event);
 static void iconExpose(WObjDescriptor * desc, XEvent * event);
 static void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_class);
-static WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile);
 static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon);
 static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon);
 
@@ -106,43 +105,59 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance
 	}
 }
 
-WAppIcon *wAppIconCreateForDock(WWindow *wwin, WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
+WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
 {
-	WAppIcon *dicon;
+	WAppIcon *aicon;
 
-	dicon = wmalloc(sizeof(WAppIcon));
-	wretain(dicon);
-	dicon->yindex = -1;
-	dicon->xindex = -1;
+	aicon = wmalloc(sizeof(WAppIcon));
+	wretain(aicon);
+
+	aicon->yindex = -1;
+	aicon->xindex = -1;
 
-	add_to_appicon_list(scr, dicon);
+	/* If wwin exists, then creating app for window,
+	 * else, creating icon for dock */
+	if (wwin) {
+		/* When no_appicon is set we want to avoid having it on the list
+		 * because otherwise there will be a hole when the icons are
+		 * arranged with wArrangeIcons() */
+		if (!WFLAGP(wwin, no_appicon))
+			add_to_appicon_list(scr, aicon);
+	} else {
+		add_to_appicon_list(scr, aicon);
+	}
 
 	if (command)
-		dicon->command = wstrdup(command);
+		aicon->command = wstrdup(command);
 
 	if (wm_class)
-		dicon->wm_class = wstrdup(wm_class);
+		aicon->wm_class = wstrdup(wm_class);
 
 	if (wm_instance)
-		dicon->wm_instance = wstrdup(wm_instance);
+		aicon->wm_instance = wstrdup(wm_instance);
 
-	dicon->icon = wIconCreate(NULL, scr, NULL, wm_instance, wm_class, tile);
+	aicon->icon = wIconCreate(wwin, scr, NULL, wm_instance, wm_class, tile);
 
 #ifdef XDND
-	wXDNDMakeAwareness(dicon->icon->core->window);
+	wXDNDMakeAwareness(aicon->icon->core->window);
 #endif
 
-	/* will be overriden by dock */
-	dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
-	dicon->icon->core->descriptor.handle_expose = iconExpose;
-	dicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
-	dicon->icon->core->descriptor.parent = dicon;
-	AddToStackList(dicon->icon->core);
+	/* will be overriden if docked */
+	aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
+	aicon->icon->core->descriptor.handle_expose = iconExpose;
+	aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
+	aicon->icon->core->descriptor.parent = aicon;
+	AddToStackList(aicon->icon->core);
+
+	if (wwin)
+		aicon->icon->show_title = 0;
+
+	wIconUpdate(aicon->icon);
 
-	return dicon;
+	return aicon;
 }
 
-void makeAppIconFor(WApplication * wapp)
+void makeAppIconFor(WApplication *wapp)
 {
 	WWindow *wwin = wapp->main_window_desc;
 
@@ -224,45 +239,6 @@ void removeAppIconFor(WApplication * wapp)
 		wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
 }
 
-WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
-{
-	WAppIcon *aicon;
-
-	aicon = wmalloc(sizeof(WAppIcon));
-	wretain(aicon);
-
-	aicon->yindex = -1;
-	aicon->xindex = -1;
-
-	/* When no_appicon is set we want to avoid having it on the list
-	 * because otherwise there will be a hole when the icons are
-	 * arranged with wArrangeIcons() */
-	if (!WFLAGP(wwin, no_appicon))
-		add_to_appicon_list(scr, aicon);
-
-	if (wm_class)
-		aicon->wm_class = wstrdup(wm_class);
-
-	if (wm_instance)
-		aicon->wm_instance = wstrdup(wm_instance);
-
-	aicon->icon = wIconCreate(wwin, scr, NULL, wm_instance, wm_class, TILE_NORMAL);
-#ifdef XDND
-	wXDNDMakeAwareness(aicon->icon->core->window);
-#endif
-
-	/* will be overriden if docked */
-	aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
-	aicon->icon->core->descriptor.handle_expose = iconExpose;
-	aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
-	aicon->icon->core->descriptor.parent = aicon;
-	AddToStackList(aicon->icon->core);
-	aicon->icon->show_title = 0;
-	wIconUpdate(aicon->icon);
-
-	return aicon;
-}
-
 void wAppIconDestroy(WAppIcon * aicon)
 {
 	WScreen *scr = aicon->icon->core->screen_ptr;
diff --git a/src/appicon.h b/src/appicon.h
index 63dc798..8e13f1c 100644
--- a/src/appicon.h
+++ b/src/appicon.h
@@ -69,8 +69,7 @@ typedef struct WAppIcon {
 	unsigned int lock:1;		 /* do not allow to be destroyed */
 } WAppIcon;
 
-WAppIcon *wAppIconCreateForDock(WWindow *wwin, WScreen *scr, char *command,
-				char *wm_instance, char *wm_class, int tile);
+WAppIcon *wAppIconCreate(WWindow *wwin, WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile);
 
 void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window);
 void wAppIconDestroy(WAppIcon *aicon);
diff --git a/src/dock.c b/src/dock.c
index a641723..c90d1f5 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -730,14 +730,14 @@ static WAppIcon *mainIconCreate(WScreen *scr, int type)
 	if (type == WM_CLIP) {
 		if (scr->clip_icon)
 			return scr->clip_icon;
-		btn = wAppIconCreateForDock(NULL, scr, NULL, "Logo", "WMClip", TILE_CLIP);
+		btn = wAppIconCreate(NULL, scr, NULL, "Logo", "WMClip", TILE_CLIP);
 		btn->icon->core->descriptor.handle_expose = clipIconExpose;
 		btn->icon->core->descriptor.handle_enternotify = clipEnterNotify;
 		btn->icon->core->descriptor.handle_leavenotify = clipLeaveNotify;
 		/*x_pos = scr->scr_width - ICON_SIZE*2 - DOCK_EXTRA_SPACE; */
 		x_pos = 0;
 	} else {
-		btn = wAppIconCreateForDock(NULL, scr, NULL, "Logo", "WMDock", TILE_NORMAL);
+		btn = wAppIconCreate(NULL, scr, NULL, "Logo", "WMDock", TILE_NORMAL);
 		x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE;
 	}
 
@@ -1391,7 +1391,7 @@ static WAppIcon *restore_icon_state(WScreen *scr, WMPropList *info, int type, in
 			return NULL;
 		}
 
-		aicon = wAppIconCreateForDock(NULL, scr, command, winstance, wclass, TILE_NORMAL);
+		aicon = wAppIconCreate(NULL, scr, command, winstance, wclass, TILE_NORMAL);
 		if (wclass)
 			wfree(wclass);
 		if (winstance)
@@ -2903,7 +2903,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window)
 				icon->launching = 1;
 				dockIconPaint(icon);
 
-				aicon = wAppIconCreateForDock(NULL, dock->screen_ptr, NULL,
+				aicon = wAppIconCreate(NULL, dock->screen_ptr, NULL,
 							      wm_instance, wm_class, TILE_NORMAL);
 				/* XXX: can: aicon->icon == NULL ? */
 				PlaceIcon(dock->screen_ptr, &x0, &y0, wGetHeadForWindow(aicon->icon->owner));
-- 
1.7.10

Reply via email to