>From fd865c97f61fd969281410e98819a9bfbc5f7f7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Thu, 5 Jul 2012 21:40:01 +0200
Subject: [PATCH 2/3] New function wAppIconCreate_real
The new function wAppIconCreate_real does the real work of wAppIconCreate
and wAppIconCreateForDock functions. These functios are now a simple interface
to simplify the calls.
---
src/appicon.c | 111 +++++++++++++++++++++++++++------------------------------
1 file changed, 52 insertions(+), 59 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 30f9b6a..e9e6979 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -68,6 +68,9 @@ 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 * leader_win);
+static WAppIcon *wAppIconCreate_real(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,40 +109,70 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char
*path, char *wm_instance
}
}
-WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char
*wm_instance, char *wm_class, int tile)
+static WAppIcon *wAppIconCreate(WWindow *wwin)
{
- WAppIcon *dicon;
+ return wAppIconCreate_real(wwin, wwin->screen_ptr, NULL,
wwin->wm_instance,
+ wwin->wm_class, TILE_NORMAL);
+}
- dicon = wmalloc(sizeof(WAppIcon));
- wretain(dicon);
- dicon->yindex = -1;
- dicon->xindex = -1;
+WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *instance,
+ char *class, int tile_type)
+{
+ return wAppIconCreate_real(NULL, scr, command, instance, class,
tile_type);
+}
- add_to_appicon_list(scr, dicon);
+static WAppIcon *wAppIconCreate_real(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;
+
+ /* 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 = wIconCreateWithIconFile(scr, wm_instance, wm_class, tile);
+ aicon->icon = wIconCreateWithIconFile(scr, 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)
@@ -222,46 +255,6 @@ void removeAppIconFor(WApplication * wapp)
wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
}
-static WAppIcon *wAppIconCreate(WWindow * leader_win)
-{
- WAppIcon *aicon;
- WScreen *scr = leader_win->screen_ptr;
-
- 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(leader_win, no_appicon))
- add_to_appicon_list(scr, aicon);
-
- if (leader_win->wm_class)
- aicon->wm_class = wstrdup(leader_win->wm_class);
-
- if (leader_win->wm_instance)
- aicon->wm_instance = wstrdup(leader_win->wm_instance);
-
- aicon->icon = wIconCreate(leader_win);
-#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;
--
1.7.10
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From fd865c97f61fd969281410e98819a9bfbc5f7f7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Thu, 5 Jul 2012 21:40:01 +0200
Subject: [PATCH 2/3] New function wAppIconCreate_real
The new function wAppIconCreate_real does the real work of wAppIconCreate
and wAppIconCreateForDock functions. These functios are now a simple interface
to simplify the calls.
---
src/appicon.c | 111 +++++++++++++++++++++++++++------------------------------
1 file changed, 52 insertions(+), 59 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 30f9b6a..e9e6979 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -68,6 +68,9 @@ 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 * leader_win);
+static WAppIcon *wAppIconCreate_real(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,40 +109,70 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance
}
}
-WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, char *wm_class, int tile)
+static WAppIcon *wAppIconCreate(WWindow *wwin)
{
- WAppIcon *dicon;
+ return wAppIconCreate_real(wwin, wwin->screen_ptr, NULL, wwin->wm_instance,
+ wwin->wm_class, TILE_NORMAL);
+}
- dicon = wmalloc(sizeof(WAppIcon));
- wretain(dicon);
- dicon->yindex = -1;
- dicon->xindex = -1;
+WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *instance,
+ char *class, int tile_type)
+{
+ return wAppIconCreate_real(NULL, scr, command, instance, class, tile_type);
+}
- add_to_appicon_list(scr, dicon);
+static WAppIcon *wAppIconCreate_real(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;
+
+ /* 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 = wIconCreateWithIconFile(scr, wm_instance, wm_class, tile);
+ aicon->icon = wIconCreateWithIconFile(scr, 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)
@@ -222,46 +255,6 @@ void removeAppIconFor(WApplication * wapp)
wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
}
-static WAppIcon *wAppIconCreate(WWindow * leader_win)
-{
- WAppIcon *aicon;
- WScreen *scr = leader_win->screen_ptr;
-
- 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(leader_win, no_appicon))
- add_to_appicon_list(scr, aicon);
-
- if (leader_win->wm_class)
- aicon->wm_class = wstrdup(leader_win->wm_class);
-
- if (leader_win->wm_instance)
- aicon->wm_instance = wstrdup(leader_win->wm_instance);
-
- aicon->icon = wIconCreate(leader_win);
-#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;
--
1.7.10