Blame src/ClDisplay.c

Packit 5bd3a9
Packit 5bd3a9
/*
Packit 5bd3a9
Packit 5bd3a9
Copyright 1985, 1990, 1998  The Open Group
Packit 5bd3a9
Packit 5bd3a9
Permission to use, copy, modify, distribute, and sell this software and its
Packit 5bd3a9
documentation for any purpose is hereby granted without fee, provided that
Packit 5bd3a9
the above copyright notice appear in all copies and that both that
Packit 5bd3a9
copyright notice and this permission notice appear in supporting
Packit 5bd3a9
documentation.
Packit 5bd3a9
Packit 5bd3a9
The above copyright notice and this permission notice shall be included
Packit 5bd3a9
in all copies or substantial portions of the Software.
Packit 5bd3a9
Packit 5bd3a9
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Packit 5bd3a9
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 5bd3a9
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Packit 5bd3a9
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
Packit 5bd3a9
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Packit 5bd3a9
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Packit 5bd3a9
OTHER DEALINGS IN THE SOFTWARE.
Packit 5bd3a9
Packit 5bd3a9
Except as contained in this notice, the name of The Open Group shall
Packit 5bd3a9
not be used in advertising or otherwise to promote the sale, use or
Packit 5bd3a9
other dealings in this Software without prior written authorization
Packit 5bd3a9
from The Open Group.
Packit 5bd3a9
Packit 5bd3a9
*/
Packit 5bd3a9
Packit 5bd3a9
#ifdef HAVE_CONFIG_H
Packit 5bd3a9
#include <config.h>
Packit 5bd3a9
#endif
Packit 5bd3a9
#include "Xxcbint.h"
Packit 5bd3a9
#include "Xlib.h"
Packit 5bd3a9
#include "Xlibint.h"
Packit 5bd3a9
#include "Xintconn.h"
Packit 5bd3a9
Packit 5bd3a9
/*
Packit 5bd3a9
 * XCloseDisplay - XSync the connection to the X Server, close the connection,
Packit 5bd3a9
 * and free all associated storage.  Extension close procs should only free
Packit 5bd3a9
 * memory and must be careful about the types of requests they generate.
Packit 5bd3a9
 */
Packit 5bd3a9
Packit 5bd3a9
int
Packit 5bd3a9
XCloseDisplay (
Packit 5bd3a9
	register Display *dpy)
Packit 5bd3a9
{
Packit 5bd3a9
	register _XExtension *ext;
Packit 5bd3a9
	register int i;
Packit 5bd3a9
Packit 5bd3a9
	if (!(dpy->flags & XlibDisplayClosing))
Packit 5bd3a9
	{
Packit 5bd3a9
	    dpy->flags |= XlibDisplayClosing;
Packit 5bd3a9
	    for (i = 0; i < dpy->nscreens; i++) {
Packit 5bd3a9
		    register Screen *sp = &dpy->screens[i];
Packit 5bd3a9
		    XFreeGC (dpy, sp->default_gc);
Packit 5bd3a9
	    }
Packit 5bd3a9
	    if (dpy->cursor_font != None) {
Packit 5bd3a9
		XUnloadFont (dpy, dpy->cursor_font);
Packit 5bd3a9
	    }
Packit 5bd3a9
	    XSync(dpy, 1);  /* throw away pending events, catch errors */
Packit 5bd3a9
	    /* call out to any extensions interested */
Packit 5bd3a9
	    for (ext = dpy->ext_procs; ext; ext = ext->next) {
Packit 5bd3a9
		if (ext->close_display)
Packit 5bd3a9
		    (*ext->close_display)(dpy, &ext->codes);
Packit 5bd3a9
	    }
Packit 5bd3a9
	    /* if the closes generated more protocol, sync them up */
Packit 5bd3a9
	    if (X_DPY_GET_REQUEST(dpy) != X_DPY_GET_LAST_REQUEST_READ(dpy))
Packit 5bd3a9
		XSync(dpy, 1);
Packit 5bd3a9
	}
Packit 5bd3a9
	xcb_disconnect(dpy->xcb->connection);
Packit 5bd3a9
	_XFreeDisplayStructure (dpy);
Packit 5bd3a9
	return 0;
Packit 5bd3a9
}