1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 22:28:02 +01:00

Split makeAppIconFor()

The function makeAppIconFor is splitted in two:

makeAppIconFor: Create the new icon if needed
paint_app_icon: Paint the icon
This commit is contained in:
Rodolfo García Peñas (kix)
2012-06-01 12:50:12 +02:00
committed by Carlos R. Mafra
parent cab8bbc495
commit 2e7b039558
2 changed files with 39 additions and 22 deletions

View File

@@ -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;
/* 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;
if (!wapp || !wapp->app_icon)
return;
icon = wapp->app_icon->icon;
wapp->app_icon->main_window = wapp->main_window;
/* 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 (!wapp->app_icon->icon->shadowed) {
wapp->app_icon->icon->shadowed = 1;
wapp->app_icon->icon->force_paint = 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(wapp->main_window_desc->screen_ptr, True);
}
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);
}

View File

@@ -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);