rem: if (XGetCommand(dpy, win, &argv, &argc) && argc>0) { command = wtokenjoin(argv, argc); XFreeStringList(argv); }
add: command = GetCommandForWindow(win);
context: makeWindowState(WWindow *wwin, WApplication *wapp){    WScreen *scr = wwin->screen_ptr;    Window win;    int argc;    char **argv;    int i;    unsigned mask;    char *class, *instance, *command=NULL, buffer[512];    WMPropList *win_state, *cmd, *name, *workspace;    WMPropList *shaded, *miniaturized, *hidden, *geometry;    WMPropList *dock, *shortcut;    if (wwin->orig_main_window!=None && wwin->orig_main_window!=wwin->client_win)        win = wwin->orig_main_window;    else        win = wwin->client_win;    if (XGetCommand(dpy, win, &argv, &argc) && argc>0) {        command = wtokenjoin(argv, argc);        XFreeStringList(argv);    }    if (!command)        return NULL;    if (PropGetWMClass(win, &class, &instance)) {        if (class && instance)            snprintf(buffer, sizeof(buffer), "%s.%s", instance, class);        else if (instance)            snprintf(buffer, sizeof(buffer), "%s", instance);        else if (class)            snprintf(buffer, sizeof(buffer), ".%s", class);        else            snprintf(buffer, sizeof(buffer), ".");        name = WMCreatePLString(buffer);        cmd = WMCreatePLString(command);        /*sprintf(buffer, "%d", wwin->frame->workspace+1);        workspace = WMCreatePLString(buffer);*/        workspace = WMCreatePLString(scr->workspaces[wwin->frame->workspace]->name);        shaded = wwin->flags.shaded ? sYes : sNo;        miniaturized = wwin->flags.miniaturized ? sYes : sNo;        hidden = wwin->flags.hidden ? sYes : sNo;        snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i", 		 wwin->client.width, wwin->client.height,		wwin->frame_x, wwin->frame_y);        geometry = WMCreatePLString(buffer);		for (mask = 0, i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {	    if (scr->shortcutWindows[i] != NULL &&		WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) {		mask |= 1<<i;	    }	}	snprintf(buffer, sizeof(buffer), "%u", mask);	shortcut = WMCreatePLString(buffer);        win_state = WMCreatePLDictionary(sName, name,                                                sCommand, cmd,                                                sWorkspace, workspace,                                                sShaded, shaded,                                                sMiniaturized, miniaturized,                                                sHidden, hidden,						sShortcutMask, shortcut,                                                sGeometry, geometry,                                                NULL);        WMReleasePropList(name);        WMReleasePropList(cmd);        WMReleasePropList(workspace);        WMReleasePropList(geometry);	WMReleasePropList(shortcut);        if (wapp && wapp->app_icon && wapp->app_icon->dock) {            int i;            char *name;            if (wapp->app_icon->dock == scr->dock) {                name="Dock";            } else {                for(i=0; i<scr->workspace_count; i++)                    if(scr->workspaces[i]->clip == wapp->app_icon->dock)                        break;                assert(i < scr->workspace_count);                /*n = i+1;*/                name = scr->workspaces[i]->name;            }            dock = WMCreatePLString(name);            WMPutInPLDictionary(win_state, sDock, dock);            WMReleasePropList(dock);        }    } else {        win_state = NULL;    }    if (instance) XFree(instance);    if (class) XFree(class);    if (command) wfree(command);    return win_state;}