home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / X / XClDisplay.c.orig < prev    next >
Encoding:
Text File  |  1991-01-29  |  1.8 KB  |  55 lines

  1. /* $XConsortium: XClDisplay.c,v 11.22 90/12/09 16:27:45 rws Exp $ */
  2. /*
  3.  
  4. Copyright 1985, 1990 by the Massachusetts Institute of Technology
  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, and that the name of M.I.T. not be used in advertising or
  11. publicity pertaining to distribution of the software without specific,
  12. written prior permission.  M.I.T. makes no representations about the
  13. suitability of this software for any purpose.  It is provided "as is"
  14. without express or implied warranty.
  15.  
  16. */
  17.  
  18. #include "Xlibint.h"
  19.  
  20. /* 
  21.  * XCloseDisplay - XSync the connection to the X Server, close the connection,
  22.  * and free all associated storage.  This is the only routine that can be
  23.  * called from or after an IOError handler, so the lower levels need to be able
  24.  * to deal with broken connections.  Extension close procs should only free
  25.  * memory and must be careful about the types of requests they generate.
  26.  */
  27.  
  28. XCloseDisplay (dpy)
  29.     register Display *dpy;
  30. {
  31.     register _XExtension *ext;
  32.     register int i;
  33.     extern void _XFreeQ();
  34.  
  35.     dpy->flags |= XlibDisplayClosing;
  36.     for (i = 0; i < dpy->nscreens; i++) {
  37.         register Screen *sp = &dpy->screens[i];
  38.         XFreeGC (dpy, sp->default_gc);
  39.     }
  40.     if (dpy->cursor_font != None) {
  41.         XUnloadFont (dpy, dpy->cursor_font);
  42.     }
  43.     XSync(dpy, 1);  /* throw away pending input events */
  44.     ext = dpy->ext_procs;
  45.     while (ext) {        /* call out to any extensions interested */
  46.         if (ext->close_display != NULL) 
  47.             (*ext->close_display)(dpy, &ext->codes);
  48.         ext = ext->next;
  49.     }    
  50.         LockDisplay(dpy);
  51.     _XDisconnectDisplay(dpy->fd);
  52.     _XFreeQ ();
  53.     return;
  54. }
  55.