[comp.windows.x] "Close" window operation under mwm

william@oahu.cs.ucla.edu (William Cheng) (05/05/91)

Under mwm (Motif Window Manager), if an application is CLOSED by
selecting the "Close" entry in the popup menu which is generated
by clicking the button on the left top portion of the window,
an XIO error often occures with the following messages:

XIO:  fatal IO error 32 (Broken pipe) on X server "rye:0.0"
      after 445 requests (89 known processed) with 0 events remaining.
      The connection was probably broken by a server shutdown or KillClient.

This happens with many applications (bitmap, xdvi, idraw, xfd, xlogo...)
but not with xloadimage, xclock, xload.  Apparently, any application that
has more than one window will get the error message.

Could someone explain this please?

I'm running on a SPARCstation with SunOS 4.1.1.  I don't know the mwm
version number.
-- 
Bill Cheng // UCLA Computer Science Department // (213) 206-7135
3277 Boelter Hall // Los Angeles, California 90024 // USA
william@CS.UCLA.EDU      ...!{uunet|ucbvax}!cs.ucla.edu!william

news@bbn.com (News system owner ID) (05/17/91)

william@oahu.cs.ucla.edu (William Cheng) writes:

|> Under mwm (Motif Window Manager), if an application is CLOSED by
|> selecting the "Close" entry in the popup menu which is generated
|> by clicking the button on the left top portion of the window,
|> an XIO error often occures with the following messages:
|> 
|> XIO:  fatal IO error 32 (Broken pipe) on X server "rye:0.0"
|>       after 445 requests (89 known processed) with 0 events remaining.
|>       The connection was probably broken by a server shutdown or KillClient.
|> 
|> This happens with many applications (bitmap, xdvi, idraw, xfd, xlogo...)
|> but not with xloadimage, xclock, xload.  Apparently, any application that
|> has more than one window will get the error message.

The "Close" item in the Motif Window Manager menu invokes mwm's "f.kill"
function, which does one of two things:

    1) Sends a ClientMessage event to the window, with 
           message_type = WM_PROTOCOLS atom
           format = 32
           data.l[0] = WM_DELETE_WINDOW atom

or
 
    2) calls XKillClient on the window, which rudely breaks
          its application's connection to the X server.

If the application has registered for the WM_DELETE_WINDOW protocol, mwm
(or any other ICCCM-compliant window manager) will do the first, giving the
application a chance to shut down gracefully (or, for that matter, to 
refuse to shut down).   xclock, for example, contains this code to
register for the protocol

    wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
                                    False);
    (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
                            &wm_delete_window, 1);

and this code to handle the resulting ClientMessage event:

    XtOverrideTranslations(toplevel,
                    XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));

along with a quit() action procedure that calls XCloseDisplay() and exit().

If the application hasn't registered for WM_DELETE_WINDOW,
mwm does the second action (XKillClient).  The application will die with an
XIOError the next time it tries to read from the (now closed) X
socket.  That's what you're seeing.  Many of MIT's officially distributed
X clients don't register for WM_DELETE_WINDOW.

For more information, look at sections 4.1.2.7, 4.2.8, and (especially)
5.2.2 of the Inter-Client Communication Conventions Manual (ICCCM).  Also
section 14.3.4 ("MWM Functions") of the OSF/Motif Programmer's Guide, 
which describes the "f.kill" function.

Note that the Open Look window manager calls this same function "Quit"
(their "Close" is more like Motif's "Minimize").

/Ron Newman	rnewman@bbn.com
Ron Newman		rnewman@bbn.com