Delayed delivery of xlib-generated events

Simon Copar info.ised at gmail.com
Thu Dec 1 10:21:29 PST 2011


I am developing a window manager as a personal
project and I hit a curious problem. Part of the
operation is mapping and unmapping windows,
but UnmapNotify events must also be caught
as clients sometimes request this.

The problem:

When I explicitly call
XUnmapWindow(...)
the UnmapNotify event does not arrive immediately,
but only after a few other functions are called.
It sometimes happens that UnmapNotify comes so late
another XMapWindow is called before, which causes all sorts of trouble.
I called XSync and XFlush, but this only flushes the output
buffer and the events seem to be stuck at the server side.
The XPending call claims there is nothing there until more stuff happens.

Am I correct the events are stuck in the server queue?
Is this intended behaviour of xlib?
Is there a possibility to force the server to send out all the signals?
Is there a common mistake I might be making?

I subscribe for the StructureNotify events.

My event loop is a poll call that also polls another socket:

while(running){
    int ret=poll(fdlist,2,-1);
    if(ret==-1){
      if(errno==EINTR)continue;
      perror("poll returned -1, error: ");
      break;
    }
    //omitted hangup testing
    if(fdlist[0].revents&POLLIN){//event has come
      XEvent ev;
      while(XPending(dpy)){
        if(XNextEvent(dpy,&ev)){  say("xnextevent failed\n");  break;  }
        if(handler[ev.type])handler[ev.type](&ev);//execute handler
        XSync(dpy,False);//does nothing
      }
    }
    //the other socket
...
}

Help appreciated!
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20111201/19dcf4f5/attachment.html>


More information about the xorg mailing list