ICCCM Window Deletion

Carsten Haitzler (The Rasterman) raster at rasterman.com
Sat Apr 22 21:14:57 PDT 2006


On Sun, 23 Apr 2006 14:10:34 +1000 Russell Shaw <rjshaw at netspace.net.au>
babbled:

> Hi,
> In the ICCCM, it says:
> 
>    4.2.8.1. Window Deletion
>    Clients, usually those with multiple top-level windows, whose server
> connection must survive the deletion of some of their top-level windows,
> should include the atom WM_DELETE_WINDOW in the WM_PROTOCOLS property on each
> such window. They will receive a ClientMessage event as described above whose
> data[0] field is WM_DELETE_WINDOW.
> 
> Why does destroying a client top-level window terminate the server connection
> if it has more than one top-level window?

it doesn't itself terminate the connection (XKillClient does this when u feel
like being evil). BUT what happens invariably is this:

window is destroyed, now the window id the client has is invalid as the window
doesn't exist. sooner or later the client will try and DO something with that id
(as it never bothered listening to destroy events on its window) and THEN x
will send back a "bad resource id" error. xlib's default behavior on such
errors is to literally terminate the process. you can override this by setting
your own handlers but most toolkits don't do this nor standard xlib apps. wm's
tend to as they are often at the nasty-end of the stick when it comes to events,
window id's etc. sure now you say "well listen for destroy events!" - yup. cool
-b ut instead  now u handle it right most of the time - but you have a race
condition where the destroy may have happened but you have not received (and
processed) the destroy notify event because x is async, and there is a window
in which you can get a bad resource id error. then the solution is to set an
error handler and listen for destroy events - now we are getting to a
complexity realm on par with the above mentioned WM_DELETE protocol - which the
above has the added advantage of giving the app a CHOICE as to how/where/when
to delete the window nicely and cleanly (if there is important data in the
window it can pop up a "are you sure" dialog for example).

remember this doesn't STOP a wm from destroying the window. it still can (and
in some cases will) - this is all a "lets be nice citizens" specification.


> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    raster at rasterman.com
裸好多
Tokyo, Japan (東京 日本)



More information about the xorg mailing list