Subject: Re: how to check if a window exists

From: Dominik Vogt <[email-masked]>
Date: Sat, 27 Nov 1999 15:15:11 +0100

On Tue, Apr 06, 1999 at 10:43:39AM -0400, Brad Giaccio wrote:
> On Sat, Apr 03, 1999 at 02:39:26AM +0200, Dominik Vogt wrote:
> > There is a minor bug (#78) that occurs when a window
> > doesn't exist anymore when fvwm processes a button
> > press that went into that window (can happen with server
> > grabs). A way to work around this would be to check if
> > the window exists before handling the event. Any ideas
> > how to check if a window with a given id exists (without
> > generating a BadWindow)?
> 
> Dominik,
> Well after some searching this is the best I could find was:
> 
> Status XQueryTree(display, w, root_return, parent_return,
>      children_return, nchildren_return)
>            Display *display;
>            Window w;
>            Window *root_return;
>            Window *parent_return;
>            Window **children_return;
>            unsigned int *nchildren_return;
> 
> Now this call can can still throw a badWindow error if you pass it
> a nonexistent window dispite what the man page says.  But what you
> could do is pass the root window as the arg to w and then check the
> children_return list for the window before you continue handling it.
> The only problem here is that once you get the list back you need to do
> a linear search to find it, and then you have to free the elements of
> the list as well.
> 
> Well that is the best I could find, although it is pretty stupid of Xlib
> to through and error but no give you any way to check for it first.

Shrug; I finally fixed the bug by calling XGetGeometry at the start
of HandleButtonPress.  The BadWindow is ignored anyway.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]