add: }
context: wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type){    WDock *dock;    WMPropList *apps;    WMPropList *value;    WAppIcon *aicon, *old_top;    int count, i;    dock = wDockCreate(scr, type);    if (!dock_state)        return dock;    if (dock_state)        WMRetainPropList(dock_state);    /* restore position */    value = WMGetFromPLDictionary(dock_state, dPosition);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("Position");        else {	    WMRect rect;	    int flags;            if (sscanf(WMGetFromPLString(value), "%i,%i", &dock->x_pos,                       &dock->y_pos)!=2)                COMPLAIN("Position");            /* check position sanity */	    rect.pos.x = dock->x_pos;	    rect.pos.y = dock->y_pos;	    rect.size.width = rect.size.height = ICON_SIZE;			    wGetRectPlacementInfo(scr, rect, &flags);	    if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) {		int x = dock->x_pos;		wScreenKeepInside(scr, &x, &dock->y_pos, ICON_SIZE, ICON_SIZE);	    }            /* This is no more needed. ??? */            if (type == WM_CLIP) {                if (dock->x_pos < 0)                    dock->x_pos = 0;                else if (dock->x_pos > scr->scr_width-ICON_SIZE)                    dock->x_pos = scr->scr_width-ICON_SIZE;            } else {                if (dock->x_pos >= 0) {                    dock->x_pos = DOCK_EXTRA_SPACE;                    dock->on_right_side = 0;                } else {                    dock->x_pos = scr->scr_width - DOCK_EXTRA_SPACE - ICON_SIZE;                    dock->on_right_side = 1;                }            }        }    }    /* restore lowered/raised state */    dock->lowered = 0;    value = WMGetFromPLDictionary(dock_state, dLowered);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("Lowered");        else {            if (strcasecmp(WMGetFromPLString(value), "YES")==0)                dock->lowered = 1;        }    }    /* restore collapsed state */    dock->collapsed = 0;    value = WMGetFromPLDictionary(dock_state, dCollapsed);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("Collapsed");        else {            if (strcasecmp(WMGetFromPLString(value), "YES")==0)                dock->collapsed = 1;        }    }    /* restore auto-collapsed state */    value = WMGetFromPLDictionary(dock_state, dAutoCollapse);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("AutoCollapse");        else {	    if (strcasecmp(WMGetFromPLString(value), "YES")==0) {                dock->auto_collapse = 1;		dock->collapsed = 1;	    }        }    }    /* restore auto-raise/lower state */    value = WMGetFromPLDictionary(dock_state, dAutoRaiseLower);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("AutoRaiseLower");        else {	    if (strcasecmp(WMGetFromPLString(value), "YES")==0) {                dock->auto_raise_lower = 1;	    }        }    }    /* restore attract icons state */    dock->attract_icons = 0;    value = WMGetFromPLDictionary(dock_state, dAutoAttractIcons);    if (value) {        if (!WMIsPLString(value))            COMPLAIN("AutoAttractIcons");        else {            if (strcasecmp(WMGetFromPLString(value), "YES")==0)                dock->attract_icons = 1;        }    }    /* application list */        {	WMPropList *tmp;	char buffer[64];		/*	 * When saving, it saves the dock state in	 * Applications and Applicationsnnn	 * 	 * When loading, it will first try Applicationsnnn.	 * If it does not exist, use Applications as default.	 */		snprintf(buffer, sizeof(buffer), "Applications%i", scr->scr_height);	tmp = WMCreatePLString(buffer);	apps = WMGetFromPLDictionary(dock_state, tmp);	WMReleasePropList(tmp);	if (!apps) {	    apps = WMGetFromPLDictionary(dock_state, dApplications);	}    }    if (!apps) {        goto finish;    }    count = WMGetPropListItemCount(apps);    if (count==0)        goto finish;    old_top = dock->icon_array[0];    /* dock->icon_count is set to 1 when dock is created.     * Since Clip is already restored, we want to keep it so for clip,     * but for dock we may change the default top tile, so we set it to 0.     */    if (type == WM_DOCK)        dock->icon_count = 0;    for (i=0; i<count; i++) {        if (dock->icon_count >= dock->max_icons) {            wwarning(_("there are too many icons stored in dock. Ignoring what doesn't fit"));            break;        }        value = WMGetFromPLArray(apps, i);        aicon = restore_icon_state(scr, value, type, dock->icon_count);        dock->icon_array[dock->icon_count] = aicon;        if (aicon) {            aicon->dock = dock;            aicon->x_pos = dock->x_pos + (aicon->xindex*ICON_SIZE);            aicon->y_pos = dock->y_pos + (aicon->yindex*ICON_SIZE);            if (dock->lowered)                ChangeStackingLevel(aicon->icon->core, WMNormalLevel);            else                ChangeStackingLevel(aicon->icon->core, WMDockLevel);            wCoreConfigure(aicon->icon->core, aicon->x_pos, aicon->y_pos,                           0, 0);            if (!dock->collapsed)                XMapWindow(dpy, aicon->icon->core->window);            wRaiseFrame(aicon->icon->core);            dock->icon_count++;        } else if (dock->icon_count==0 && type==WM_DOCK)            dock->icon_count++;    }    /* if the first icon is not defined, use the default */    if (dock->icon_array[0]==NULL) {        /* update default icon */        old_top->x_pos = dock->x_pos;        old_top->y_pos = dock->y_pos;        if (dock->lowered)            ChangeStackingLevel(old_top->icon->core, WMNormalLevel);        else            ChangeStackingLevel(old_top->icon->core, WMDockLevel);        dock->icon_array[0] = old_top;        XMoveWindow(dpy, old_top->icon->core->window, dock->x_pos, dock->y_pos);        /* we don't need to increment dock->icon_count here because it was         * incremented in the loop above.         */    } else if (old_top!=dock->icon_array[0]) {        if (old_top == scr->clip_icon)            scr->clip_icon = dock->icon_array[0];        wAppIconDestroy(old_top);    }finish:    if (dock_state)        WMReleasePropList(dock_state);    return dock;}