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