| 1 |
|
| 2 |
/* |
| 3 |
|
| 4 |
Copyright 1985, 1990, 1998 The Open Group |
| 5 |
|
| 6 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 7 |
documentation for any purpose is hereby granted without fee, provided that |
| 8 |
the above copyright notice appear in all copies and that both that |
| 9 |
copyright notice and this permission notice appear in supporting |
| 10 |
documentation. |
| 11 |
|
| 12 |
The above copyright notice and this permission notice shall be included |
| 13 |
in all copies or substantial portions of the Software. |
| 14 |
|
| 15 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 |
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 |
OTHER DEALINGS IN THE SOFTWARE. |
| 22 |
|
| 23 |
Except as contained in this notice, the name of The Open Group shall |
| 24 |
not be used in advertising or otherwise to promote the sale, use or |
| 25 |
other dealings in this Software without prior written authorization |
| 26 |
from The Open Group. |
| 27 |
|
| 28 |
*/ |
| 29 |
|
| 30 |
#ifdef HAVE_CONFIG_H |
| 31 |
#include <config.h> |
| 32 |
#endif |
| 33 |
#if USE_XCB |
| 34 |
#include "Xxcbint.h" |
| 35 |
#else /* !USE_XCB */ |
| 36 |
#include <nx-X11/Xtrans/Xtrans.h> |
| 37 |
#endif /* USE_XCB */ |
| 38 |
#include "Xlib.h" |
| 39 |
#include "Xlibint.h" |
| 40 |
#include "Xintconn.h" |
| 41 |
|
| 42 |
/* |
| 43 |
* XCloseDisplay - XSync the connection to the X Server, close the connection, |
| 44 |
* and free all associated storage. Extension close procs should only free |
| 45 |
* memory and must be careful about the types of requests they generate. |
| 46 |
*/ |
| 47 |
|
| 48 |
int |
| 49 |
XCloseDisplay ( |
| 50 |
register Display *dpy) |
| 51 |
{ |
| 52 |
register _XExtension *ext; |
| 53 |
register int i; |
| 54 |
|
| 55 |
if (!(dpy->flags & XlibDisplayClosing)) |
| 56 |
{ |
| 57 |
dpy->flags |= XlibDisplayClosing; |
| 58 |
for (i = 0; i < dpy->nscreens; i++) { |
| 59 |
register Screen *sp = &dpy->screens[i]; |
| 60 |
XFreeGC (dpy, sp->default_gc); |
| 61 |
} |
| 62 |
if (dpy->cursor_font != None) { |
| 63 |
XUnloadFont (dpy, dpy->cursor_font); |
| 64 |
} |
| 65 |
XSync(dpy, 1); /* throw away pending events, catch errors */ |
| 66 |
/* call out to any extensions interested */ |
| 67 |
for (ext = dpy->ext_procs; ext; ext = ext->next) { |
| 68 |
if (ext->close_display) |
| 69 |
(*ext->close_display)(dpy, &ext->codes); |
| 70 |
} |
| 71 |
/* if the closes generated more protocol, sync them up */ |
| 72 |
if (dpy->request != dpy->last_request_read) |
| 73 |
XSync(dpy, 1); |
| 74 |
} |
| 75 |
#if USE_XCB |
| 76 |
xcb_disconnect(dpy->xcb->connection); |
| 77 |
#else /* !USE_XCB */ |
| 78 |
_XDisconnectDisplay(dpy->trans_conn); |
| 79 |
#endif /* USE_XCB */ |
| 80 |
_XFreeDisplayStructure (dpy); |
| 81 |
return 0; |
| 82 |
} |