Raise/Map and Focus a window: BadMatch error

Russell Shaw rjshaw at netspace.net.au
Tue Dec 18 16:42:00 PST 2007


Andrew Troschinetz wrote:
> Hello everyone,
> 
> I'm struggling with xlib here since I've been given a project that  
> requires a lot of low level window management and I've never really  
> done any coding with xlib before now. Currently I have an issue with  
> XSetInputFocus().
> 
> What I'm trying to do is write a function that will:
> 	1. Map a window (if it's unmapped)
> 	2. Raise it
> 	3. Focus that window
> 
> Here's what I've got thus far:
> 
> void map_raise_focus(Display *display, Window window) {
> 	XEvent e;
> 	XSelectInput (display, windw, ExposureMask);
> 	XMapRaised (display, window);
> 	while (e.type != Expose) {
> 		XNextEvent (display, &e);
> 	}
> 	XSelectInputFocus (display, window, RevertToParent, CurrentTime);
> }
> 
> Sometimes (not always) I get a BadMatch error (Details: serial 2738  
> error_code 8 request_code 42 minor_code 0) which I'm sure is being  
> caused by my XSelectInputFocus() call. I have a feeling that I'm doing  
> something very wrong here but looking at the docs I can't seem to  
> figure out how one would go about writing a function like  
> map_raise_focus().
> 
> Can anyone shed some light on this problem for me please?

Make X synchronous and BadMatch errors will be easier to find.

XSynchronize

http://tronche.com/gui/x/xlib/event-handling/protocol-errors/XSynchronize.html



More information about the xorg mailing list