Raise/Map and Focus a window: BadMatch error

Andrew Troschinetz ast at arlut.utexas.edu
Wed Dec 19 07:55:53 PST 2007


On Dec 18, 2007, at 6:42 PM, Russell Shaw wrote:
> Make X synchronous and BadMatch errors will be easier to find.

Interestingly, using XPeekIfEvent() wrapped in XSynchronize(True/ 
False) calls makes the BadMatch sometimes less likely to occur. To  
reproduce the error I've been minimizing (manually, I'm in Gnome) and  
then un-minimizing via a call to my map_raise_focus() function.  
Without the XSynchronize() calls this gives the error on either the  
first or second attempt to un-minimize.  With XSynchronize() calls it  
sometimes (though sometimes not) takes about 10 tries, but the error  
always does eventually happen.

I've looked over the code that is being executed in its entirety to  
check if any other Xlib function could have caused a BadMatch error  
and it appears XSetInputFocus() is the only culprit.

Just for reference, in the code that's being executed I've only got  
these functions:
	XPeekIfEvent()
	XSelectInput()
	XGetWindowAttributes()
	XMapRaised()
	XSetInputFocus()
	XGetWindowProperty()
	XGetWMName()
	XFree()

Even assuming I'm not using one of those correctly, none of them but  
the XSetInputFocus() can cause a BadMatch, or is there a way I can get  
BadMatch some other way?


Incidentally, since XSynchronize() was able to give me sometimes more  
stability I thought that maybe the solution that uses XWindowEvent()  
is also only exhibiting sometimes more stability as well. So I tried  
as hard as I could to crash the program that's using XWindowEvent()  
but I just can't do it, it appears to work all the time whereas the  
XPeekIfEvent() fails very quickly.

I also printed out the values of the XEvent that causes the do-while- 
XWindowEvent() loop to exit and the XEvent returned by XPeekIfEvent()  
and they're the same --- So XPeekIfEvent() and XWindowEvent() are  
returning the same event exactly how I want them to, but one fails and  
the other doesn't. So yeah, I'm completely clueless now. Maybe I _DO_  
want to remove the XEvent from the event queue?

On Dec 18, 2007, at 6:10 PM, Peter Harris wrote:
> The only remaining thing I can think of is the return type: Bool.

The only includes I've got are X11 headers, stl headers, and ctime  
which makes errors like this less likely. I just checked that I didn't  
typedef of #define Bool/True/False to be sure but nope that's not the  
problem either. I even changed all True to 1, False to 0, and Bool to  
int just to be extra double for sure ;) No luck.

--
Andrew Troschinetz
Applied Research Laboratories
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20071219/4e71bb0e/attachment.html>


More information about the xorg mailing list