I am developing a window manager as a personal<br>project and I hit a curious problem. Part of the<br>operation is mapping and unmapping windows,<br>but UnmapNotify events must also be caught<br>as clients sometimes request this.<br>
<br>The problem:<br><br>When I explicitly call<br>XUnmapWindow(...)<br>the UnmapNotify event does not arrive immediately,<br>but only after a few other functions are called.<br>It sometimes happens that UnmapNotify comes so late<br>
another
XMapWindow is called before, which causes all sorts of trouble.<br>I called XSync and XFlush, but this only flushes the output<br>buffer and the events seem to be stuck at the server side.<br>The XPending call claims there is nothing there until more stuff happens.<br>
<br>Am I correct the events are stuck in the server queue?<br>Is this intended behaviour of xlib?<br>
Is there a possibility to force the server to send out all the signals?<br>Is there a common mistake I might be making?<br><br>I subscribe for the StructureNotify events.<br><br>My event loop is a poll call that also polls another socket:<br>
<br>while(running){<br> int ret=poll(fdlist,2,-1);<br> if(ret==-1){<br> if(errno==EINTR)continue;<br> perror("poll returned -1, error: ");<br> break;<br> }<br> //omitted hangup testing<br>
if(fdlist[0].revents&POLLIN){//event has come<br> XEvent ev;<br> while(XPending(dpy)){<br> if(XNextEvent(dpy,&ev)){ say("xnextevent failed\n"); break; }<br> if(handler[ev.type])handler[ev.type](&ev);//execute handler<br>
XSync(dpy,False);//does nothing<br> }<br> }<br> //the other socket<br>...<br>}<br><br>Help appreciated!<br>Thanks.<br><br>