11ab64890Smrg
21ab64890Smrg/*
31ab64890Smrg
41ab64890SmrgCopyright 1985, 1990, 1998  The Open Group
51ab64890Smrg
61ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its
71ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that
81ab64890Smrgthe above copyright notice appear in all copies and that both that
91ab64890Smrgcopyright notice and this permission notice appear in supporting
101ab64890Smrgdocumentation.
111ab64890Smrg
121ab64890SmrgThe above copyright notice and this permission notice shall be included
131ab64890Smrgin all copies or substantial portions of the Software.
141ab64890Smrg
151ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
161ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
171ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
181ab64890SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
191ab64890SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
201ab64890SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
211ab64890SmrgOTHER DEALINGS IN THE SOFTWARE.
221ab64890Smrg
231ab64890SmrgExcept as contained in this notice, the name of The Open Group shall
241ab64890Smrgnot be used in advertising or otherwise to promote the sale, use or
251ab64890Smrgother dealings in this Software without prior written authorization
261ab64890Smrgfrom The Open Group.
271ab64890Smrg
281ab64890Smrg*/
291ab64890Smrg
301ab64890Smrg#ifdef HAVE_CONFIG_H
311ab64890Smrg#include <config.h>
321ab64890Smrg#endif
331ab64890Smrg#include "Xxcbint.h"
341ab64890Smrg#include "Xlib.h"
351ab64890Smrg#include "Xlibint.h"
361ab64890Smrg#include "Xintconn.h"
371ab64890Smrg
3861b2299dSmrg/*
391ab64890Smrg * XCloseDisplay - XSync the connection to the X Server, close the connection,
401ab64890Smrg * and free all associated storage.  Extension close procs should only free
411ab64890Smrg * memory and must be careful about the types of requests they generate.
421ab64890Smrg */
431ab64890Smrg
441ab64890Smrgint
451ab64890SmrgXCloseDisplay (
461ab64890Smrg	register Display *dpy)
471ab64890Smrg{
481ab64890Smrg	register _XExtension *ext;
491ab64890Smrg	register int i;
5007fb9b8fSmrg	xcb_connection_t *connection;
511ab64890Smrg
521ab64890Smrg	if (!(dpy->flags & XlibDisplayClosing))
531ab64890Smrg	{
541ab64890Smrg	    dpy->flags |= XlibDisplayClosing;
551ab64890Smrg	    for (i = 0; i < dpy->nscreens; i++) {
561ab64890Smrg		    register Screen *sp = &dpy->screens[i];
571ab64890Smrg		    XFreeGC (dpy, sp->default_gc);
581ab64890Smrg	    }
591ab64890Smrg	    if (dpy->cursor_font != None) {
601ab64890Smrg		XUnloadFont (dpy, dpy->cursor_font);
611ab64890Smrg	    }
621ab64890Smrg	    XSync(dpy, 1);  /* throw away pending events, catch errors */
631ab64890Smrg	    /* call out to any extensions interested */
641ab64890Smrg	    for (ext = dpy->ext_procs; ext; ext = ext->next) {
651ab64890Smrg		if (ext->close_display)
661ab64890Smrg		    (*ext->close_display)(dpy, &ext->codes);
671ab64890Smrg	    }
681ab64890Smrg	    /* if the closes generated more protocol, sync them up */
692d67cb4fSmrg	    if (X_DPY_GET_REQUEST(dpy) != X_DPY_GET_LAST_REQUEST_READ(dpy))
701ab64890Smrg		XSync(dpy, 1);
711ab64890Smrg	}
7207fb9b8fSmrg	connection = dpy->xcb->connection;
731ab64890Smrg	_XFreeDisplayStructure (dpy);
7407fb9b8fSmrg	xcb_disconnect(connection);
751ab64890Smrg	return 0;
761ab64890Smrg}
77