Window shutdown program by Janet L. Carson, Baylor College of Medicine.
Version 1.0, Placed in /contrib on 2/12/90.

Please send comments or fixes to jcarson@bcm.tmc.edu

Usage:

    xclosedown [-d display-string]

What it is:

    This program attempts to close down all applications which have opened
    a window up on a given display.  It is a useful way of ending a session
    on an X Terminal without leaving "zombies."

    I have compiled it on a sun4, and run it successfully on a SPARCstation 1
    and an NCD X-Terminal, using X11R4 libraries from MIT.  

How it works:

    I open the display and use XQueryTree to locate the various windows on
    the display.  

    Pass 1: Top-level windows are recognized by looking for the WM_STATE
    property.  Once a top-level window is found, if the window supports
    WM_DELETE_WINDOW, I use XSendEvent to send it that WM_PROTOCOL. 
    Otherwise, I do an XKillClient on it.

    Pass 2: First, I sleep for 2 seconds to allow applications to clean
    themselves up.  Then I do an XKillClient on any remaining windows.

    An error handler catches problems with windows disappearing while I'm
    querying the window tree.

Bugs/Limitations:

    If an ICCCM-compliant window manager has never run on the display during
    the session, the top level windows will not have had WM_STATE placed upon 
    them.  No windows will get killed until the second pass, when they will 
    all be terminated with XKillClient.  The alternative would be to key off 
    of WM_COMMAND or something placed by the client: this would cause me to 
    miss all ICCCM non-compliant applications.  (Such applications are 
    currently caught, as long as the window manager is ICCCM-compliant.)

    You may want to change the sleep time or eliminate pass 2 all together.
    (Applications started up between the passes will be rudely terminated!)
    I have successfully closed down the environment with just pass 1 using
    twm, but I fail to kill swm in that manner.  (The twm icon manager looks
    just like another top-level window, so twm gets killed through that, I 
    believe.  Window managers do not generally treat their own menu windows
    and reparenting windows as top-level windows, so I don't catch them with
    pass 1.)

Plea for help:

    If you have any comments or fixes for this program, please send them
    to the author, Janet Carson, jcarson@bcm.tmc.edu.  Thank you!
