From cab8bbc4958ef8d9e4bbfe2c2d9d578e6863e1f1 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:40:44 +0200 Subject: [PATCH] Move makeAppIconFor() and removeAppIconFor() The functions makeAppIconFor and removeAppIconFor are moved from winspector.c to appicon.c, and now are not static. The reason to move these functions is because are used to create and remove app_icons, therefore should be included in this file. Finally, this functions will be updated and splitted in next patches. --- src/appicon.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/appicon.h | 3 +++ src/winspector.c | 66 -------------------------------------------------------- 3 files changed, 69 insertions(+), 66 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 4c966433..9016600a 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -44,6 +44,7 @@ #include "menu.h" #include "framewin.h" #include "dialog.h" +#include "xinerama.h" #include "client.h" #ifdef XDND #include "xdnd.h" @@ -116,6 +117,71 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, return dicon; } +void makeAppIconFor(WApplication * wapp) +{ + WScreen *scr = wapp->main_window_desc->screen_ptr; + + if (wapp->app_icon) + return; + + if (!WFLAGP(wapp->main_window_desc, no_appicon)) + wapp->app_icon = wAppIconCreate(wapp->main_window_desc); + 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; + + wapp->app_icon->main_window = wapp->main_window; + + 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); + + if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted) + wArrangeIcons(wapp->main_window_desc->screen_ptr, True); + } +} + +void removeAppIconFor(WApplication * wapp) +{ + if (!wapp->app_icon) + return; + + if (wapp->app_icon->docked && !wapp->app_icon->attracted) { + wapp->app_icon->running = 0; + /* since we keep it, we don't care if it was attracted or not */ + wapp->app_icon->attracted = 0; + wapp->app_icon->icon->shadowed = 0; + wapp->app_icon->main_window = None; + wapp->app_icon->pid = 0; + wapp->app_icon->icon->owner = NULL; + wapp->app_icon->icon->icon_win = None; + wapp->app_icon->icon->force_paint = 1; + wAppIconPaint(wapp->app_icon); + } else if (wapp->app_icon->docked) { + wapp->app_icon->running = 0; + wDockDetach(wapp->app_icon->dock, wapp->app_icon); + } else { + wAppIconDestroy(wapp->app_icon); + } + wapp->app_icon = NULL; + if (wPreferences.auto_arrange_icons) + wArrangeIcons(wapp->main_window_desc->screen_ptr, True); +} + WAppIcon *wAppIconCreate(WWindow * leader_win) { WAppIcon *aicon; diff --git a/src/appicon.h b/src/appicon.h index fab712a1..0c28cbb8 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -76,7 +76,10 @@ WAppIcon * wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, void wAppIconDestroy(WAppIcon *aicon); void wAppIconPaint(WAppIcon *aicon); void wAppIconMove(WAppIcon *aicon, int x, int y); +void makeAppIconFor(WApplication * wapp); +void removeAppIconFor(WApplication * wapp); void save_app_icon(WWindow *wwin, WApplication *wapp); + Bool wAppIconChangeImage(WAppIcon *icon, char *file); Bool wAppIconSave(WAppIcon *aicon); #endif diff --git a/src/winspector.c b/src/winspector.c index a5857104..dae8c298 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -47,7 +47,6 @@ #include "dock.h" #include "client.h" #include "wmspec.h" -#include "xinerama.h" #include @@ -674,71 +673,6 @@ static void saveSettings(WMButton * button, InspectorPanel * panel) WMPLSetCaseSensitive(False); } -static void makeAppIconFor(WApplication * wapp) -{ - WScreen *scr = wapp->main_window_desc->screen_ptr; - - if (wapp->app_icon) - return; - - if (!WFLAGP(wapp->main_window_desc, no_appicon)) - wapp->app_icon = wAppIconCreate(wapp->main_window_desc); - 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; - - wapp->app_icon->main_window = wapp->main_window; - - 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); - - if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted) - wArrangeIcons(wapp->main_window_desc->screen_ptr, True); - } -} - -static void removeAppIconFor(WApplication * wapp) -{ - if (!wapp->app_icon) - return; - - if (wapp->app_icon->docked && !wapp->app_icon->attracted) { - wapp->app_icon->running = 0; - /* since we keep it, we don't care if it was attracted or not */ - wapp->app_icon->attracted = 0; - wapp->app_icon->icon->shadowed = 0; - wapp->app_icon->main_window = None; - wapp->app_icon->pid = 0; - wapp->app_icon->icon->owner = NULL; - wapp->app_icon->icon->icon_win = None; - wapp->app_icon->icon->force_paint = 1; - wAppIconPaint(wapp->app_icon); - } else if (wapp->app_icon->docked) { - wapp->app_icon->running = 0; - wDockDetach(wapp->app_icon->dock, wapp->app_icon); - } else { - wAppIconDestroy(wapp->app_icon); - } - wapp->app_icon = NULL; - if (wPreferences.auto_arrange_icons) - wArrangeIcons(wapp->main_window_desc->screen_ptr, True); -} - static void applySettings(WMButton * button, InspectorPanel * panel) { WWindow *wwin = panel->inspected; -- 2.11.4.GIT