Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!infonode!jon From: jon@infonode.ingr.com (Jon Stone) Newsgroups: comp.windows.x Subject: Re: Help! What is the magic of the sleep() statement? Message-ID: <1991Jan9.222321.13732@infonode.ingr.com> Date: 9 Jan 91 22:23:21 GMT References: <1991Jan9.150326.6248@warwick.ac.uk> Reply-To: jon@ingr.com Organization: Intergraph Corp. Huntsville, AL Lines: 32 In article <1991Jan9.150326.6248@warwick.ac.uk> csuyk@warwick.ac.uk (FUNG Wai Wa) writes: >The following few statements attempt to create a window and draw a line >with some strings. I found that the sleep(1) statement is very crucial >for its success. Its presence can make the program work as I expect but >its absence make the program map the windows only. No drawing at all, if >I run this program from another machine. Occasionally I can get it running >in the same workstation where I started X. I'm no x-spert, but I think you need to wait for an Expose event before doing any drawing. X automagically queues up an Expose event when you map your window. This code is far from perfect. Try reading Chapter 3 of the Xlib Programming Manual. It should fill you in on the details. Try something like this: all your init stuff. XMapRaised XSelectInput (dpy, win, ExposureMask); while (1) { XNextEvent (dpy, &event); if (event.type == Expose) draw } Jon -- _______________________________________________________________________________ Jon D. Stone jon@ingr.com -or- ..!uunet!ingr!jon Intergraph Corporation, Huntsville, AL (205)730-8594 _______________________________________________________________________________