Raise/Map and Focus a window: BadMatch error

Tomas Carnecky tom at dbservice.com
Tue Dec 18 11:43:17 PST 2007


Andrew Troschinetz wrote:
> 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:

If that is the real code as you use it in your app, see the comment below.

> 
> void map_raise_focus(Display *display, Window window) {
> 	XEvent e;
> 	XSelectInput (display, windw, ExposureMask);
> 	XMapRaised (display, window);
> 	while (e.type != Expose) {
                ^^^^^^
'e' is uninitialized here!

> 		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().
> 

tom



More information about the xorg mailing list