rem: if (wPreferences.window_placement == WPM_MANUAL) dontBring = True; } else if (scr->xine_info.count && wwin->normal_hints->flags & PPosition) {
add: if (wPreferences.window_placement == WPM_MANUAL) { dontBring = True; } } else if (scr->xine_info.count && (wwin->normal_hints->flags & PPosition)) {
context: wManageWindow(WScreen *scr, Window window){    WWindow *wwin;    int x, y;    unsigned width, height;    XWindowAttributes wattribs;        XSetWindowAttributes attribs;    WWindowState *win_state;    WWindow *transientOwner = NULL;    int window_level;    int wm_state;    int foo;    int workspace = -1;    char *title;    Bool withdraw = False;    Bool raise = False;    /* mutex. */    /* XGrabServer(dpy); */    XSync(dpy, False);    /* make sure the window is still there */    if (!XGetWindowAttributes(dpy, window, &wattribs)) {	XUngrabServer(dpy);	return NULL;    }    /* if it's an override-redirect, ignore it */    if (wattribs.override_redirect) {	XUngrabServer(dpy);	return NULL;    }    wm_state = PropGetWindowState(window);    /* if it's startup and the window is unmapped, don't manage it */    if (scr->flags.startup && wm_state < 0 && wattribs.map_state==IsUnmapped) {	XUngrabServer(dpy);	return NULL;    }    if (!wFetchName(dpy, window, &title)) {	title = NULL;    }#ifdef KWM_HINTS    if (title && !wKWMManageableClient(scr, window, title)) {	XFree(title);	XUngrabServer(dpy);	return NULL;    }#endif /* KWM_HINTS */    wwin = wWindowCreate();    XSaveContext(dpy, window, wWinContext, (XPointer)&wwin->client_descriptor);#ifdef DEBUG    printf("managing window %x\n", (unsigned)window);#endif#ifdef SHAPE    if (wShapeSupported) {	int junk;	unsigned int ujunk;	int b_shaped;		XShapeSelectInput(dpy, window, ShapeNotifyMask);	XShapeQueryExtents(dpy, window, &b_shaped, &junk, &junk, &ujunk, 			   &ujunk, &junk, &junk, &junk, &ujunk, &ujunk);	wwin->flags.shaped = b_shaped;    }#endif        /*     *--------------------------------------------------     *      * Get hints and other information in properties     *     *--------------------------------------------------      */    PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance);    /* setup descriptor */    wwin->client_win = window;    wwin->screen_ptr = scr;    wwin->old_border_width = wattribs.border_width;    wwin->event_mask = CLIENT_EVENTS;    attribs.event_mask = CLIENT_EVENTS;    attribs.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;    attribs.save_under = False;    XChangeWindowAttributes(dpy, window, CWEventMask|CWDontPropagate			    |CWSaveUnder, &attribs);        XSetWindowBorderWidth(dpy, window, 0);    /* get hints from GNUstep app */    if (wwin->wm_class != 0 && strcmp(wwin->wm_class, "GNUstep") == 0) {	wwin->flags.is_gnustep = 1;    }    if (!PropGetGNUstepWMAttr(window, &wwin->wm_gnustep_attr)) {	wwin->wm_gnustep_attr = NULL;    }    wwin->client_leader = PropGetClientLeader(window);    if (wwin->client_leader!=None)	wwin->main_window = wwin->client_leader;    wwin->wm_hints = XGetWMHints(dpy, window);    if (wwin->wm_hints)  {	if (wwin->wm_hints->flags & StateHint) {	    if (wwin->wm_hints->initial_state == IconicState) {		wwin->flags.miniaturized = 1;	    } else if (wwin->wm_hints->initial_state == WithdrawnState) {		withdraw = True;	    }	}	if (wwin->wm_hints->flags & WindowGroupHint) {	    wwin->group_id = wwin->wm_hints->window_group;	    /* window_group has priority over CLIENT_LEADER */	    wwin->main_window = wwin->group_id;	} else {	    wwin->group_id = None;	}	if (wwin->wm_hints->flags & UrgencyHint)	  wwin->flags.urgent = 1;    } else {	wwin->group_id = None;    }    PropGetProtocols(window, &wwin->protocols);    if (!XGetTransientForHint(dpy, window, &wwin->transient_for)) {	wwin->transient_for = None;    } else {	if (wwin->transient_for==None || wwin->transient_for==window) {	    wwin->transient_for = scr->root_win;	} else {	    transientOwner = wWindowFor(wwin->transient_for);	    if (transientOwner && transientOwner->main_window!=None) {		wwin->main_window = transientOwner->main_window;            } /*else {		wwin->main_window = None;            }*/	}    }    /* guess the focus mode */    wwin->focus_mode = getFocusMode(wwin);    /* get geometry stuff */    wClientGetNormalHints(wwin, &wattribs, True, &x, &y, &width, &height);/*    printf( "wManageWindow: %d %d %d %d\n", x, y, width, height);*/    /* get colormap windows */    GetColormapWindows(wwin);    /*     *--------------------------------------------------     *      * Setup the decoration/window attributes and     * geometry     *      *--------------------------------------------------     */    wWindowSetupInitialAttributes(wwin, &window_level, &workspace);#ifdef OLWM_HINTS    if (wwin->client_flags.olwm_transient && wwin->transient_for==None	&& wwin->group_id != None && wwin->group_id != window) {	transientOwner = wWindowFor(wwin->group_id);	if (transientOwner) {	    wwin->transient_for = wwin->group_id;	    /* transients can't be iconified or maximized */	    if (wwin->transient_for) {		WSETUFLAG(wwin, no_miniaturizable, 1);		WSETUFLAG(wwin, no_miniaturize_button, 1);	    }	}    }#endif /* OLWM_HINTS */    /* Make broken apps behave as a nice app. */    if (WFLAGP(wwin, emulate_appicon)) {	wwin->main_window = wwin->client_win;    }    wwin->orig_main_window = wwin->main_window;    if (wwin->flags.is_gnustep) {        WSETUFLAG(wwin, shared_appicon, 0);    }    if (wwin->main_window) {        extern Atom _XA_WINDOWMAKER_MENU;        XTextProperty text_prop;        if (XGetTextProperty(dpy, wwin->main_window, &text_prop,                             _XA_WINDOWMAKER_MENU)) {            WSETUFLAG(wwin, shared_appicon, 0);        }    }    if (!withdraw && wwin->main_window && WFLAGP(wwin, shared_appicon)) {        char *buffer, *instance, *class;        WFakeGroupLeader *fPtr;        int index;#define ADEQUATE(x) ((x)!=None && (x)!=wwin->client_win && (x)!=fPtr->leader)	        PropGetWMClass(wwin->main_window, &class, &instance);	buffer = StrConcatDot(instance, class);        index = WMFindInArray(scr->fakeGroupLeaders, matchIdentifier, (void*)buffer);        if (index != WANotFound) {            fPtr = WMGetFromArray(scr->fakeGroupLeaders, index);            if (fPtr->retainCount == 0) {                fPtr->leader = createFakeWindowGroupLeader(scr, wwin->main_window,                                                           instance, class);            }            fPtr->retainCount++;#undef method2            if (fPtr->origLeader==None) {#ifdef method2                if (ADEQUATE(wwin->group_id)) {                    fPtr->retainCount++;                    fPtr->origLeader = wwin->group_id;                } else if (ADEQUATE(wwin->client_leader)) {                    fPtr->retainCount++;                    fPtr->origLeader = wwin->client_leader;                } else if (ADEQUATE(wwin->main_window)) {                    fPtr->retainCount++;                    fPtr->origLeader = wwin->main_window;                }#else                if (ADEQUATE(wwin->main_window)) {                    fPtr->retainCount++;                    fPtr->origLeader = wwin->main_window;                }#endif            }            wwin->fake_group = fPtr;            /*wwin->group_id = fPtr->leader;*/            wwin->main_window = fPtr->leader;            wfree(buffer);        } else {            fPtr = (WFakeGroupLeader*)wmalloc(sizeof(WFakeGroupLeader));            fPtr->identifier = buffer;            fPtr->leader = createFakeWindowGroupLeader(scr, wwin->main_window,                                                       instance, class);            fPtr->origLeader = None;            fPtr->retainCount = 1;            WMAddToArray(scr->fakeGroupLeaders, fPtr);#ifdef method2            if (ADEQUATE(wwin->group_id)) {                fPtr->retainCount++;                fPtr->origLeader = wwin->group_id;            } else if (ADEQUATE(wwin->client_leader)) {                fPtr->retainCount++;                fPtr->origLeader = wwin->client_leader;            } else if (ADEQUATE(wwin->main_window)) {                fPtr->retainCount++;                fPtr->origLeader = wwin->main_window;            }#else            if (ADEQUATE(wwin->main_window)) {                fPtr->retainCount++;                fPtr->origLeader = wwin->main_window;            }#endif            wwin->fake_group = fPtr;            /*wwin->group_id = fPtr->leader;*/            wwin->main_window = fPtr->leader;        }        if (instance)            XFree(instance);        if (class)            XFree(class);#undef method2#undef ADEQUATE    }    /*     *------------------------------------------------------------     *     * Setup the initial state of the window     *     *------------------------------------------------------------     */    if (WFLAGP(wwin, start_miniaturized) && !WFLAGP(wwin, no_miniaturizable)) {	wwin->flags.miniaturized = 1;    }    if (WFLAGP(wwin, start_maximized) && !WFLAGP(wwin, no_resizable)) {	wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL;    }    {	Bool bla;		bla = False;#ifdef GNOME_STUFF	bla = wGNOMECheckInitialClientState(wwin);#endif#ifdef KWM_HINTS	if (!bla)	    wKWMCheckClientInitialState(wwin);#endif    }    /* apply previous state if it exists and we're in startup */    if (scr->flags.startup && wm_state >= 0) {	if (wm_state == IconicState) {	    wwin->flags.miniaturized = 1;	} else if (wm_state == WithdrawnState) {	    withdraw = True;	}    }    /* if there is a saved state (from file), restore it */    win_state = NULL;    if (wwin->main_window!=None/* && wwin->main_window!=window*/) {        win_state = (WWindowState*)wWindowGetSavedState(wwin->main_window);    } else {        win_state = (WWindowState*)wWindowGetSavedState(window);    }    if (win_state && !withdraw) {        if (win_state->state->hidden>0)            wwin->flags.hidden = win_state->state->hidden;        if (win_state->state->shaded>0 && !WFLAGP(wwin, no_shadeable))            wwin->flags.shaded = win_state->state->shaded;        if (win_state->state->miniaturized>0 &&	    !WFLAGP(wwin, no_miniaturizable)) {            wwin->flags.miniaturized = win_state->state->miniaturized;        }        if (!IS_OMNIPRESENT(wwin)) {            int w = wDefaultGetStartWorkspace(scr, wwin->wm_instance,                                              wwin->wm_class);            if (w < 0 || w >= scr->workspace_count) {                workspace = win_state->state->workspace;                if (workspace >= scr->workspace_count)                    workspace = scr->current_workspace;            } else {                workspace = w;            }        } else {            workspace = scr->current_workspace;        }    }    /* if we're restarting, restore saved state (from hints).      * This will overwrite previous */    {	WSavedState *wstate;	if (getSavedState(window, &wstate)) {	    wwin->flags.shaded = wstate->shaded;	    wwin->flags.hidden = wstate->hidden;	    wwin->flags.miniaturized = wstate->miniaturized;	    wwin->flags.maximized = wstate->maximized;	    if (wwin->flags.maximized) {		wwin->old_geometry.x = wstate->x;		wwin->old_geometry.y = wstate->y;		wwin->old_geometry.width = wstate->w;		wwin->old_geometry.height = wstate->h;	    }	    workspace = wstate->workspace;	} else {	    wstate = NULL;	}	/* restore window shortcut */	if (wstate != NULL || win_state != NULL) {	    unsigned mask = 0;	    if (win_state != NULL)		mask = win_state->state->window_shortcuts;	    	    if (wstate != NULL && mask == 0)		mask = wstate->window_shortcuts;	    if (mask > 0) {		int i;		for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {		    if (mask & (1<<i)) {			if (!scr->shortcutWindows[i])			    scr->shortcutWindows[i] = WMCreateArray(4);			WMAddToArray(scr->shortcutWindows[i], wwin);		    }		}	    }	}	if (wstate != NULL) {	    wfree(wstate);	}    }    /* don't let transients start miniaturized if their owners are not */    if (transientOwner && !transientOwner->flags.miniaturized	&& wwin->flags.miniaturized && !withdraw) {	wwin->flags.miniaturized = 0;	if (wwin->wm_hints)	    wwin->wm_hints->initial_state = NormalState;    }    /* set workspace on which the window starts */        if (workspace >= 0) {	if (workspace > scr->workspace_count-1) {	    workspace = workspace % scr->workspace_count;	}    } else {	int w;	w = wDefaultGetStartWorkspace(scr, wwin->wm_instance, wwin->wm_class);        if (w >= 0 && w < scr->workspace_count && !(IS_OMNIPRESENT(wwin))) {            workspace = w;        } else {	    if (wPreferences.open_transients_with_parent && transientOwner) {		workspace = transientOwner->frame->workspace;	    } else {		workspace = scr->current_workspace;	    }        }    }    /* setup window geometry */    if (win_state && win_state->state->w > 0) {        width = win_state->state->w;        height = win_state->state->h;    }    wWindowConstrainSize(wwin, &width, &height);    /* do not ask for window placement if the window is     * transient, during startup, if the initial workspace is another one     * or if the window wants to start iconic.     * If geometry was saved, restore it. */    {	Bool dontBring = False;	if (win_state && win_state->state->w > 0) {	    x = win_state->state->x;	    y = win_state->state->y;	} else if ((wwin->transient_for==None		    || wPreferences.window_placement!=WPM_MANUAL)		   && !scr->flags.startup 		   && workspace == scr->current_workspace		   && !wwin->flags.miniaturized		   && !wwin->flags.maximized		   && !(wwin->normal_hints->flags & (USPosition|PPosition))) {	    	    if (transientOwner && transientOwner->flags.mapped) {		int offs = WMAX(20, 2*transientOwner->frame->top_width);		WMRect rect;		int head;				x = transientOwner->frame_x + 		    abs((transientOwner->frame->core->width - width)/2) + offs;		y = transientOwner->frame_y +		    abs((transientOwner->frame->core->height - height)/3) + offs;		/*		 * limit transient windows to be inside their parent's head		 */		rect.pos.x = transientOwner->frame_x;		rect.pos.y = transientOwner->frame_y;		rect.size.width = transientOwner->frame->core->width;		rect.size.height = transientOwner->frame->core->height;				head = wGetHeadForRect(scr, rect);		rect = wGetRectForHead(scr, head);				if (x < rect.pos.x)		    x = rect.pos.x;		else if (x + width > rect.pos.x + rect.size.width)		    x = rect.pos.x + rect.size.width - width;				if (y < rect.pos.y)		    y = rect.pos.y;		else if (y + height > rect.pos.y + rect.size.height)		    y = rect.pos.y + rect.size.height - height;	    } else {		PlaceWindow(wwin, &x, &y, width, height);	    }	    if (wPreferences.window_placement == WPM_MANUAL)		dontBring = True;	} 	else if (scr->xine_info.count &&		  wwin->normal_hints->flags & PPosition) {	    int head, flags;	    WMRect rect;	    int reposition = 0;	    	    /*	     * Make spash screens come out in the center of a head	     * trouble is that most splashies never get here	     * they are managed trough atoms but god knows where.	     * Dan, do you know ?	     * 	     * Most of them are not managed, they are set	     * OverrideRedirect, which means we can't do anything about	     * them. -alfredo	     */#if 0	    printf( "xinerama PPosition: x: %d %d\n", x, (scr->scr_width - width)/2);	    printf( "xinerama PPosition: y: %d %d\n", y, (scr->scr_height - height)/2);	    if ( (unsigned)(x + (width - scr->scr_width)/2 + 10) < 20 &&		 (unsigned)(y + (height - scr->scr_height)/2 + 10) < 20) {		reposition = 1;	    } else #endif	    {		/*		 * xinerama checks for: across head and dead space		 */		rect.pos.x = x;		rect.pos.y = y;		rect.size.width = width;		rect.size.height = height;		head = wGetRectPlacementInfo(scr, rect, &flags);		if (flags & XFLAG_DEAD)		    reposition = 1;		if (flags & XFLAG_MULTIPLE)		    reposition = 2;	    }	    	    switch (reposition) {	     case 1:		head = wGetHeadForPointerLocation(scr);		rect = wGetRectForHead(scr, head);				x = rect.pos.x + (x * rect.size.width)/scr->scr_width;		y = rect.pos.y + (y * rect.size.height)/scr->scr_height;		break;			     case 2:		rect = wGetRectForHead(scr, head);				if (x < rect.pos.x)		    x = rect.pos.x;		else if (x + width > rect.pos.x + rect.size.width)		    x = rect.pos.x + rect.size.width - width;				if (y < rect.pos.y)		    y = rect.pos.y;		else if (y + height > rect.pos.y + rect.size.height)		    y = rect.pos.y + rect.size.height - height;				break;			     default:		break;	    }	}	if (WFLAGP(wwin, dont_move_off) && dontBring)	    wScreenBringInside(scr, &x, &y, width, height);    }    if (wwin->flags.urgent) {	if (!IS_OMNIPRESENT(wwin))	    wwin->flags.omnipresent ^= 1;    }    /*     *--------------------------------------------------     *      * Create frame, borders and do reparenting     *     *--------------------------------------------------     */    foo = WFF_LEFT_BUTTON | WFF_RIGHT_BUTTON;#ifdef XKB_BUTTON_HINT    if (wPreferences.modelock)        foo |= WFF_LANGUAGE_BUTTON;#endif    if (!WFLAGP(wwin, no_titlebar))	foo |= WFF_TITLEBAR;    if (!WFLAGP(wwin, no_resizebar))	foo |= WFF_RESIZEBAR;    if (!WFLAGP(wwin, no_border))	foo |= WFF_BORDER;    wwin->frame = wFrameWindowCreate(scr, window_level, 				     x, y, width, height,				     &wPreferences.window_title_clearance, foo,				     scr->window_title_texture,				     scr->resizebar_texture,				     scr->window_title_color,				     &scr->title_font);    wwin->frame->flags.is_client_window_frame = 1;    wwin->frame->flags.justification = wPreferences.title_justification;    /* setup button images */    wWindowUpdateButtonImages(wwin);    /* hide unused buttons */    foo = 0;    if (WFLAGP(wwin, no_close_button))	foo |= WFF_RIGHT_BUTTON;    if (WFLAGP(wwin, no_miniaturize_button))	foo |= WFF_LEFT_BUTTON;#ifdef XKB_BUTTON_HINT    if (WFLAGP(wwin, no_language_button) || WFLAGP(wwin, no_focusable))        foo |= WFF_LANGUAGE_BUTTON;#endif    if (foo!=0)	wFrameWindowHideButton(wwin->frame, foo);    wwin->frame->child = wwin;#ifdef OLWM_HINTS    /* emulate olwm push pin. Make the button look as pushed-in for     * the pinned-out state. When the button is clicked, it will     * revert to the normal position, which means the pin is pinned-in.     */    if (wwin->flags.olwm_push_pin_out)	wFrameWindowUpdatePushButton(wwin->frame, True);#endif /* OLWM_HINTS */    wwin->frame->workspace = workspace;    wwin->frame->on_click_left = windowIconifyClick;#ifdef XKB_BUTTON_HINT    if (wPreferences.modelock)        wwin->frame->on_click_language = windowLanguageClick;#endif    wwin->frame->on_click_right = windowCloseClick;    wwin->frame->on_dblclick_right = windowCloseDblClick;    wwin->frame->on_mousedown_titlebar = titlebarMouseDown;    wwin->frame->on_dblclick_titlebar = titlebarDblClick;    wwin->frame->on_mousedown_resizebar = resizebarMouseDown;    XSelectInput(dpy, wwin->client_win,		 wwin->event_mask & ~StructureNotifyMask);    XReparentWindow(dpy, wwin->client_win, wwin->frame->core->window,		    0, wwin->frame->top_width);    XSelectInput(dpy, wwin->client_win, wwin->event_mask);    {	int gx, gy;	wClientGetGravityOffsets(wwin, &gx, &gy);	/* if gravity is to the south, account for the border sizes */	if (gy > 0)	    y -= wwin->frame->top_width + wwin->frame->bottom_width;    }    /*      * wWindowConfigure() will init the client window's size     * (wwin->client.{width,height}) and all other geometry     * related variables (frame_x,frame_y)     */    wWindowConfigure(wwin, x, y, width, height);    /* to make sure the window receives it's new position after reparenting */    wWindowSynthConfigureNotify(wwin);    /*     *--------------------------------------------------     *      * Setup descriptors and save window to internal     * lists     *     *--------------------------------------------------     */    if (wwin->main_window!=None) {	WApplication *app;	WWindow *leader;	/* Leader windows do not necessary set themselves as leaders.	 * If this is the case, point the leader of this window to	 * itself */	leader = wWindowFor(wwin->main_window);	if (leader && leader->main_window==None) {	    leader->main_window = leader->client_win;	}	app = wApplicationCreate(scr, wwin->main_window);        if (app) {            app->last_workspace = workspace;            app->main_window_desc->fake_group = wwin->fake_group;            /*             * Do application specific stuff, like setting application             * wide attributes.             */            if (wwin->flags.hidden) {                /* if the window was set to hidden because it was hidden                 * in a previous incarnation and that state was restored */                app->flags.hidden = 1;            } else if (app->flags.hidden) {                if (WFLAGP(app->main_window_desc, start_hidden)) {                    wwin->flags.hidden = 1;                } else {                    wUnhideApplication(app, False, False);                    raise = True;                }            }        }    }    /* setup the frame descriptor */    wwin->frame->core->descriptor.handle_mousedown = frameMouseDown;    wwin->frame->core->descriptor.parent = wwin;    wwin->frame->core->descriptor.parent_type = WCLASS_WINDOW;    /* don't let windows go away if we die */    XAddToSaveSet(dpy, window);    XLowerWindow(dpy, window);    /* if window is in this workspace and should be mapped, then  map it */    if (!wwin->flags.miniaturized	&& (workspace == scr->current_workspace || IS_OMNIPRESENT(wwin))        && !wwin->flags.hidden && !withdraw) {        /* The following "if" is to avoid crashing of clients that expect         * WM_STATE set before they get mapped. Else WM_STATE is set later,         * after the return from this function.         */        if (wwin->wm_hints && (wwin->wm_hints->flags & StateHint)) {            wClientSetState(wwin, wwin->wm_hints->initial_state, None);        } else {            wClientSetState(wwin, NormalState, None);        }#if 0	/* if not auto focus, then map the window under the currently	 * focused window */#define _WIDTH(w) (w)->frame->core->width#define _HEIGHT(w) (w)->frame->core->height	if (!wPreferences.auto_focus && scr->focused_window	    && !scr->flags.startup && !transientOwner	    && ((wWindowObscuresWindow(wwin, scr->focused_window)		 && (_WIDTH(wwin) > (_WIDTH(scr->focused_window)*5)/3		     || _HEIGHT(wwin) > (_HEIGHT(scr->focused_window)*5)/3)		 && WINDOW_LEVEL(scr->focused_window) == WINDOW_LEVEL(wwin))		|| wwin->flags.maximized)) {	    MoveInStackListUnder(scr->focused_window->frame->core,				 wwin->frame->core);	}#undef _WIDTH#undef _HEIGHT#endif	if (wPreferences.superfluous && !wPreferences.no_animations            && !scr->flags.startup &&            (wwin->transient_for==None || wwin->transient_for==scr->root_win)	    /* 	     * The brain damaged idiotic non-click to focus modes will	     * have trouble with this because:	     * 	     * 1. window is created and mapped by the client	     * 2. window is mapped by wmaker in small size	     * 3. window is animated to grow to normal size	     * 4. this function returns to normal event loop	     * 5. eventually, the EnterNotify event that would trigger	     * the window focusing (if the mouse is over that window)	     * will be processed by wmaker.	     * But since this event will be rather delayed 	     * (step 3 has a large delay) the time when the event ocurred	     * and when it is processed, the client that owns that window	     * will reject the XSetInputFocus() for it.	     */	    && (wPreferences.focus_mode==WKF_CLICK		|| wPreferences.auto_focus)) {	    DoWindowBirth(wwin);	}        wWindowMap(wwin);    }    /* setup stacking descriptor */    if (transientOwner) {        wwin->frame->core->stacking->child_of = transientOwner->frame->core;    } else {	wwin->frame->core->stacking->child_of = NULL;    }    if (!scr->focused_window) {	/* first window on the list */	wwin->next = NULL;	wwin->prev = NULL;	scr->focused_window = wwin;    } else {	WWindow *tmp;	/* add window at beginning of focus window list */	tmp = scr->focused_window;	while (tmp->prev)	    tmp = tmp->prev;	tmp->prev = wwin;	wwin->next = tmp;	wwin->prev = NULL;    }    /* raise is set to true if we un-hid the app when this window was born.     * we raise, else old windows of this app will be above this new one. */    if (raise) {        wRaiseFrame(wwin->frame->core);    }    /* Update name must come after WApplication stuff is done */    wWindowUpdateName(wwin, title);    if (title)	XFree(title);        XUngrabServer(dpy);    /*     *--------------------------------------------------     *     * Final preparations before window is ready to go     *     *--------------------------------------------------     */    wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED);    if (!wwin->flags.miniaturized && workspace == scr->current_workspace	&& !wwin->flags.hidden) {	if (((transientOwner && transientOwner->flags.focused)	     || wPreferences.auto_focus) && !WFLAGP(wwin, no_focusable))	    wSetFocusTo(scr, wwin);    }    wWindowResetMouseGrabs(wwin);    if (!WFLAGP(wwin, no_bind_keys)) {	wWindowSetKeyGrabs(wwin);    }    WMPostNotificationName(WMNManaged, wwin, NULL);    wColormapInstallForWindow(scr, scr->cmap_window);    #ifdef OLWM_HINTS    if (wwin->client_flags.olwm_warp_to_pin && wwin->frame->titlebar != NULL	&& !WFLAGP(wwin, no_close_button) && !withdraw) {	XWarpPointer(dpy, None, None, 0, 0, 0, 0,		     wwin->frame_x + width - wwin->frame->titlebar->height * 2,		     wwin->frame_y);    }#endif    /*     *------------------------------------------------------------     * Setup Notification Observers     *------------------------------------------------------------     */    WMAddNotificationObserver(appearanceObserver, wwin,			      WNWindowAppearanceSettingsChanged, wwin);        /*     *--------------------------------------------------     *      *  Cleanup temporary stuff     *     *--------------------------------------------------     */    if (win_state)        wWindowDeleteSavedState(win_state);    /* If the window must be withdrawed, then do it now.     * Must do some optimization, 'though */    if (withdraw) {	wwin->flags.mapped = 0;	wClientSetState(wwin, WithdrawnState, None);	wUnmanageWindow(wwin, True, False);	wwin = NULL;    }    return wwin;}