add: if (wapp->app_icon) { char *tmp;   tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True); if (!tmp) extractClientIcon(wapp->app_icon); }
context: wApplicationCreate(WScreen *scr, Window main_window){    WApplication *wapp;    WWindow *leader;    if (main_window==None || main_window==scr->root_win) {#ifdef DEBUG0	wwarning("trying to create application for %x",(unsigned)main_window);#endif	return NULL;    }    {	Window root;	int foo;	unsigned int bar;	/* check if the window is valid */	if (!XGetGeometry(dpy, main_window, &root, &foo, &foo, &bar, &bar,			  &bar, &bar)) {	    return NULL;	}    }        wapp = wApplicationOf(main_window);    if (wapp) {	wapp->refcount++;	return wapp;    }        wapp = wmalloc(sizeof(WApplication));    memset(wapp, 0, sizeof(WApplication));    wapp->refcount = 1;    wapp->last_focused = NULL;        wapp->last_workspace = 0;          wapp->main_window = main_window;    wapp->main_window_desc = makeMainWindow(scr, main_window);    if (!wapp->main_window_desc) {	free(wapp);	return NULL;    }        extractIcon(wapp->main_window_desc);    leader = wWindowFor(main_window);    if (leader) {	leader->main_window = main_window;    }    wapp->menu = wAppMenuGet(scr, main_window);    /*     * Set application wide attributes from the leader.     */    wapp->flags.hidden = wapp->main_window_desc->window_flags.start_hidden;        wapp->flags.emulated = wapp->main_window_desc->window_flags.emulate_appicon;    /* application descriptor */    XSaveContext(dpy, main_window, wAppWinContext, (XPointer)wapp);    if (!wapp->main_window_desc->window_flags.no_appicon) {        wapp->app_icon = NULL;        if (scr->last_dock)            wapp->app_icon = findDockIconFor(scr->last_dock, main_window);        /* check main dock if we did not find it in last dock */        if (!wapp->app_icon && scr->dock)	    wapp->app_icon = findDockIconFor(scr->dock, main_window);        /* finally check clips */        if (!wapp->app_icon) {            int i;            for (i=0; i<scr->workspace_count; i++) {                WDock *dock = scr->workspaces[i]->clip;                if (dock)                    wapp->app_icon = findDockIconFor(dock, main_window);                if (wapp->app_icon)                    break;            }        }                            if (wapp->app_icon) {            WWindow *mainw = wapp->main_window_desc;            wapp->app_icon->running = 1;            wapp->app_icon->icon->force_paint = 1;            wapp->app_icon->icon->owner = mainw;            if (mainw->wm_hints && (mainw->wm_hints->flags&IconWindowHint))                wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;            wAppIconPaint(wapp->app_icon);        } else {	    wapp->app_icon = wAppIconCreate(wapp->main_window_desc);#ifdef REDUCE_APPICONS	/* This is so we get the appearance of invoking the app sitting	 * on the dock. -cls */	    if (wapp->app_icon) {		if (wapp->app_icon->docked && wapp->app_icon->num_apps == 1) {		    wapp->app_icon->launching = 0;		    wapp->app_icon->running = 1;		    wapp->app_icon->icon->force_paint = 1;		    wAppIconPaint(wapp->app_icon);		}	    }#endif	}    } else {	wapp->app_icon = NULL;    }        if (wapp->app_icon) {        wapp->app_icon->main_window = main_window;#ifdef WMSOUND        wSoundServerGrab(wapp->app_icon->wm_class, main_window);#endif    }#ifndef REDUCE_APPICONS    if (wapp->app_icon && !wapp->app_icon->docked) {#else    if (wapp->app_icon && !wapp->app_icon->docked && wapp->app_icon->num_apps == 1) {#endif        WIcon *icon = wapp->app_icon->icon;        WDock *clip = scr->workspaces[scr->current_workspace]->clip;        int x=0, y=0;        if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {            wapp->app_icon->attracted = 1;            if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {                wapp->app_icon->icon->shadowed = 1;                wapp->app_icon->icon->force_paint = 1;                /* We don't do an wAppIconPaint() here because it's in                 * wDockAttachIcon(). -Dan                 */            }            wDockAttachIcon(clip, wapp->app_icon, x, y);        } else {            PlaceIcon(scr, &x, &y);	    wAppIconMove(wapp->app_icon, x, y);#ifndef STRICTNS            wLowerFrame(icon->core);#endif        }        if (!clip || !wapp->app_icon->attracted || !clip->collapsed)	    XMapWindow(dpy, icon->core->window);    }    if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted) {	wArrangeIcons(scr, True);    }    wapp->prev = NULL;     wapp->next = scr->wapp_list;    if (scr->wapp_list)	scr->wapp_list->prev = wapp;    scr->wapp_list = wapp;#ifdef WMSOUND    wSoundPlay(WMSOUND_APPSTART);#endif#ifdef DEBUG    printf("Created application for %x\n", (unsigned)main_window);#endif    return wapp;}