Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!mit-eddie!bloom-beacon!dont-send-mail-to-path-lines From: pete@iris49.UUCP (Pete Ware) Newsgroups: comp.windows.x Subject: XFlush/XSync inside the widget or in the app Message-ID: <9102181926.AA09347@iris49.biosym.com> Date: 18 Feb 91 19:26:40 GMT References: <1991Feb15.164855.2480@thyme.jpl.nasa.gov> Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 47 I still maintain that as a philisophical issue, neither an application nor a widget should call XFlush() or XSync(). kaleb> An application that performs computationally intensive kaleb> routines, and wants to manage a popup dialog notifying the user kaleb> to wait. If the buffer is not flushed with either an XFlush or kaleb> XSync, there is no guarantee that the popup will be mapped. kaleb> Using XFlush or XSync after managing will ensure this. This kaleb> example has been a frequent topic in c.w.x.m. In this case, even an XFlush or XSync will not guarantee the popup is displayed. You are assuming that the expose event will occur closely enough after a XMapWindow that the XSync will get the expose -- it isn't true. To do this right you need to enter into an event loop until the popup can say that yes, I'm done drawing (it needs to do an XFlush). But this is definitely a special case. kaleb> As we are using Motif, we can't go adding to these widgets, but for kaleb> the widgets we are writing, we have a clean slate. So to re-iterate kaleb> my original question: If we have a widget that is internally doing kaleb> a large amount of drawing, where should we do the XFlush/Xsync, inside kaleb> or outside the widget? I'd probably hide inside the widget just because one should minimize how dependent an application is on the implementation. (It's also a pain later when you realize the call the XFlush() is a mistake and you have to go traipsing all over your code to remove it). But to try to convince you not to do it: Do you use stdio? Do you turn off all buffering for each stream? Do you even call fflush()? Think of XFlush() as being equivalent. You're sending a message to stderr so you want it to appear right away, just like creating a popup to warn the user about something. This means flushing the output is ok. On the other hand, if you are doing lots of output, you probably want it to be as efficient as possible -- just because you _are_ doing lots of output. I also object to using XSync because it (1) forces a round trip to the server; (2) is probably hiding timing errors on the relative fast connection and server that you are doing your development on -- as soon as someone runs your application against a slow server it's going to at best display incorrectly and at worst break. --pete Pete Ware / Biosym / San Diego CA / (619) 546-5532 uucp: scripps.edu!bioc1!pete Internet: bioc1!pete@scripps.edu