This patch includes the icon_create() and icon_draw() functions.

These functions are used to create the icon and map it on the screen.

Signed-off-by: Rodolfo García Peñas (kix) <[email protected]>
---
 src/icon.c | 69 ++++++++++++++++++++++++++++++++------------------------------
 src/icon.h |  2 ++
 2 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index f4d4856..9a2b38a 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -112,37 +112,45 @@ static int getSize(Drawable d, unsigned int *w, unsigned 
int *h, unsigned int *d
        return XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep);
 }
 
-WIcon *icon_create_for_wwindow(WWindow *wwin)
+WIcon *icon_create(const char *command, const char *wm_instance, const char 
*wm_class, int tile)
 {
-       WScreen *scr = wwin->screen_ptr;
        WIcon *icon;
 
        icon = icon_create_core();
-       set_icon_image_from_database(icon, wwin->wm_instance, wwin->wm_class, 
NULL);
-       icon->tile_type = TILE_NORMAL;
+       set_icon_image_from_database(icon, wm_instance, wm_class, command);
+       icon->tile_type = tile;
+
+       return icon;
+}
 
-       wcore_map_toplevel(icon->core, scr, wwin->icon_x, wwin->icon_y, 0, 
scr->w_depth,
+void icon_draw(WScreen *scr, WIcon *icon, int x, int y, WWindow *wwin)
+{
+       wcore_map_toplevel(icon->core, scr, x, y, 0, scr->w_depth,
                           scr->w_visual, scr->w_colormap, scr->white_pixel);
 
-       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 window, we are drawing a icon for a window, use their attributes 
*/
+       if (wwin) {
+               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
 
-       wIconChangeTitle(icon, wwin);
+               wIconChangeTitle(icon, wwin);
+       }
+
 
        icon->file_image = RDrawImage(scr->rcontext, icon->file_image);
        icon->file_image = wIconValidateIconSize(icon->file_image, 
wPreferences.icon_size);
@@ -152,29 +160,24 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
 
        WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
        WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
-
-       return icon;
 }
 
-WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char 
*wm_instance, const char *wm_class, int tile)
+WIcon *icon_create_for_wwindow(WWindow *wwin)
 {
        WIcon *icon;
 
-       icon = icon_create_core();
-       set_icon_image_from_database(icon, wm_instance, wm_class, command);
-       icon->tile_type = tile;
-
-       wcore_map_toplevel(icon->core, scr, 0, 0, 0, scr->w_depth,
-                          scr->w_visual, scr->w_colormap, scr->white_pixel);
+       icon = icon_create(NULL, wwin->wm_instance, wwin->wm_class, 
TILE_NORMAL);
+       icon_draw(wwin->screen_ptr, icon, wwin->icon_x, wwin->icon_y, wwin);
 
-       icon->file_image = RDrawImage(scr->rcontext, icon->file_image);
-       icon->file_image = wIconValidateIconSize(icon->file_image, 
wPreferences.icon_size);
+       return icon;
+}
 
-       /* Update the icon, because icon could be NULL */
-       wIconUpdate(icon);
+WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char 
*wm_instance, const char *wm_class, int tile)
+{
+       WIcon *icon;
 
-       WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
-       WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
+       icon = icon_create(command, wm_instance, wm_class, tile);
+       icon_draw(scr, icon, 0, 0, NULL);
 
        return icon;
 }
diff --git a/src/icon.h b/src/icon.h
index 347814b..1a14b9d 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -53,8 +53,10 @@ typedef struct WIcon {
                                         * color */
 } WIcon;
 
+WIcon *icon_create(const char *command, const char *wm_instance, const char 
*wm_class, int tile);
 WIcon *icon_create_for_dock(WScreen *scr, const char *command, const char 
*wm_instance, const char *wm_class, int tile);
 WIcon *icon_create_for_wwindow(WWindow *wwin);
+void icon_draw(WScreen *scr, WIcon *icon, int x, int y, WWindow *wwin);
 
 void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const 
char *wm_class, const char *command);
 void wIconDestroy(WIcon *icon);
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to