Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!bellcore!dana From: dana@dino.bellcore.com (Dana A. Chee) Newsgroups: comp.windows.x Subject: Re: Simple programming quiz Message-ID: Date: 16 Jun 89 11:51:47 GMT References: <29675@ucbvax.BERKELEY.EDU> <3184@ncsuvx.ncsu.edu> Sender: news@bellcore.bellcore.com Organization: Bellcore, Morristown, NJ USA Lines: 61 In-reply-to: mauney@cscadm.ncsu.edu's message of 15 Jun 89 17:47:10 GMT In article <3184@ncsuvx.ncsu.edu> mauney@cscadm.ncsu.edu (Jon Mauney) writes: I would like to use this example as a springboard from which to jump onto a soapbox and talk about the nature of Xlib programming. Obviously, this is not actually the case. I'm certain the Consortium knows a good reason why it isn't the case. I'm damn sure they aren't going to change things at this point in the game. But the Consortium needs to make sure that the protocol definition is unambiguous about such behavior, and writers of tutorials need to make such distinctions blatantly obvious to the novice. I really should have gone further explaining this. Here's "reality". It is true that X processes events in the order received, but there are a few 'gotchas' included in this, the prime one being the window manager. When a reparenting window manager is running (um, awm, twm, etc), it tells X that it wants all Map and Configure events for the children of the Root window (all top level windows) to be rerouted to it (see SubstructureRedirectMask). This means that the following thing happens: client Xserver windowManager MapRequest ----> MapRequest ---> (forwarded to wm) DrawRequest ---> (notice map not done yet) <----- MapRequest (for client) (window now mapped, but draw already done) In a nutshell, the client sends in a MapRequest, the server forwards that request to the windowmanager. The client then sends in a Draw request, which is ignored. Some time later, after the window manager has played around (creating title bars, etc), it sends the MapRequest for the client's window to the server. At this point, the window becomes mapped. So what is missing in the discussions is that requests can be redirected, so things don't have to occur in the order you supply them. Obviously, all useful programs must have a loop that accepts expose events, since a window may be obscured in many ways. But there are many reasons to want to write code that goes for quite a while before looking at events, and during program development this is especially true. But in this case you must, because without the expose event, you don't know when the window manager has finished with your MapRequest and given it back to the server. Hope this helps clarify things. Jon Mauney Computer Science Dept, NCSU mauney@cscadm.ncsu.edu -- Dana Chee Bellcore MRE 2Q-250 (201) 829-4488 dana@bellcore.com