[comp.windows.x] How can I check for a valid Window id?

rlh2@ukc.ac.uk (Richard Hesketh) (11/14/89)

I have a window id. obtained via various means, in most cases from a
property on the root window and I wish to check whether that window
still exists in the server.  Looking at the Xlib manual in Chapter 4
I find:

4.1 Obtaining Window Information

[ ... ] Because they are most frequently used by window managers, these
functions all return a status to indicate whether the window still exists.

--

Ah, ha.  Just what I need!?  The manual does not explicity say that
the following requests can generate BadWindow errors (I want my program
to be informed of any bad windows synchronously):   XQueryTree() and
XGetGeometry().

I would like the status to be set to indicate the window doesn't
exist.

Unforturnately all these still generate BadWindow errors.  From my reading
of section 4.1 if a bad Window is passed then it should return a Status
of 0 (failure).  Should this be happening?  Is it dependent on the
Server I am connecting to?  Do I have to trap the error using an error
handler?  If I do have to install an error handler how can I re-install the
previous error handler if one had been installed (*I* cannot know about
previous handlers that may have been installed)?

Thanks,
	Richard

Richard Hesketh   :   rlh2@ukc.ac.uk    ..!mcvax!ukc!rlh2
		  :   @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk
---                                               
Computing Lab., University of Kent at Canterbury,
Canterbury, Kent, CT2 7NF, United Kingdom.         Tel: (0227) 764000 ext. 3682 

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (11/15/89)

    From my reading
    of section 4.1 if a bad Window is passed then it should return a Status
    of 0 (failure).  Should this be happening?

Yes, if your error handler returns.

    Do I have to trap the error using an error handler?

Yes.

    If I do have to install an error handler how can I re-install the
    previous error handler if one had been installed (*I* cannot know about
    previous handlers that may have been installed)?

In R4, XSetErrorHandler and XSetIOErrorHandler return the old handler.