From 2e7b039558456b98d8b453a1f61be6a4e03c597e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Fri, 1 Jun 2012 12:50:12 +0200 Subject: [PATCH] Split makeAppIconFor() The function makeAppIconFor is splitted in two: makeAppIconFor: Create the new icon if needed paint_app_icon: Paint the icon --- src/appicon.c | 60 +++++++++++++++++++++++++++++++++++++---------------------- src/appicon.h | 1 + 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 9016600a..00839443 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -119,8 +119,7 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, void makeAppIconFor(WApplication * wapp) { - WScreen *scr = wapp->main_window_desc->screen_ptr; - + /* If app_icon, work is done, return */ if (wapp->app_icon) return; @@ -129,30 +128,45 @@ void makeAppIconFor(WApplication * wapp) else wapp->app_icon = NULL; - if (wapp->app_icon) { - WIcon *icon = wapp->app_icon->icon; - WDock *clip = scr->workspaces[scr->current_workspace]->clip; - int x = 0, y = 0; + /* Now, paint the icon */ + paint_app_icon(wapp); +} + +void paint_app_icon(WApplication *wapp) +{ + WIcon *icon; + WScreen *scr = wapp->main_window_desc->screen_ptr; + WDock *clip = scr->workspaces[scr->current_workspace]->clip; + int x = 0, y = 0; - wapp->app_icon->main_window = wapp->main_window; + if (!wapp || !wapp->app_icon) + return; - if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) { - wapp->app_icon->attracted = 1; - if (!wapp->app_icon->icon->shadowed) { - wapp->app_icon->icon->shadowed = 1; - wapp->app_icon->icon->force_paint = 1; - } - wDockAttachIcon(clip, wapp->app_icon, x, y); - } else { - PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc)); - wAppIconMove(wapp->app_icon, x, y); - } - if (!clip || !wapp->app_icon->attracted || !clip->collapsed) - XMapWindow(dpy, icon->core->window); + icon = wapp->app_icon->icon; + wapp->app_icon->main_window = wapp->main_window; - if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted) - wArrangeIcons(wapp->main_window_desc->screen_ptr, True); + /* If the icon is docked, don't continue */ + if (wapp->app_icon->docked) + return; + + if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) { + wapp->app_icon->attracted = 1; + if (!icon->shadowed) { + icon->shadowed = 1; + icon->force_paint = 1; + } + wDockAttachIcon(clip, wapp->app_icon, x, y); + } else { + PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc)); + wAppIconMove(wapp->app_icon, x, y); + wLowerFrame(icon->core); } + + if (!clip || !wapp->app_icon->attracted || !clip->collapsed) + XMapWindow(dpy, icon->core->window); + + if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted) + wArrangeIcons(scr, True); } void removeAppIconFor(WApplication * wapp) @@ -177,7 +191,9 @@ void removeAppIconFor(WApplication * wapp) } else { wAppIconDestroy(wapp->app_icon); } + wapp->app_icon = NULL; + if (wPreferences.auto_arrange_icons) wArrangeIcons(wapp->main_window_desc->screen_ptr, True); } diff --git a/src/appicon.h b/src/appicon.h index 0c28cbb8..774c3e34 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -79,6 +79,7 @@ void wAppIconMove(WAppIcon *aicon, int x, int y); void makeAppIconFor(WApplication * wapp); void removeAppIconFor(WApplication * wapp); void save_app_icon(WWindow *wwin, WApplication *wapp); +void paint_app_icon(WApplication *wapp); Bool wAppIconChangeImage(WAppIcon *icon, char *file); Bool wAppIconSave(WAppIcon *aicon); -- 2.11.4.GIT