Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!mit-eddie!uw-beaver!ubc-cs!alberta!daniel From: daniel@cs.UAlberta.CA (Daniel Lanovaz) Newsgroups: comp.windows.x.motif Subject: Re: XmUpdateDisplay fails Message-ID: <1991Apr8.162933.21613@cs.UAlberta.CA> Date: 8 Apr 91 16:29:33 GMT References: <1991Apr5.153900.22674@athena.mit.edu> <20738@paperboy.OSF.ORG> Sender: news@cs.UAlberta.CA (News Administrator) Distribution: inet Organization: University of Alberta, Edmonton, Canada Lines: 63 In article <20738@paperboy.OSF.ORG> dbrooks@osf.org (David Brooks) writes: >alice@athena.mit.edu (Timothy R Wall) writes: >|> I use XmUpdateDisplay to refresh my application before starting a long >|> load from disk and subsequent calculation. Immediately after >|> XmUpdateDisplay I call a routine to change the cursor, which calls >|> XFlush; I see the cursor change, but no screen update. What's wrong? > >This turns out not to be the case. The server may have delivered the >events, but the client hasn't received them yet. There's a timing issue, >which may (or not) involve the window manager, and some of us are looking >into a better solution. For now, you can try: > > XSync(XtDisplay(toplevel), 0); > usleep(); > XmUpdateDisplay(toplevel); > >where on my workstation is 60000. Is it possible to process events sent from the server while in a compute- bound system module by having the events interrupt your process while it is computing? I have experimented with something like the following. It seems to work with the programs I use it in, but there may be problems I don't see (for instance, what to do if the SIGIO interrupt was not generated by the ConnectionNumber(Display) socket)? InstallEventHandler(topLevel); DoSomeVeryLongCalculation(); RemoveEventHandler(topLevel); XEventHandler(/* Some parameters here */) { XEvent anEvent; while(XtPending()) { XtNextEvent(&anEvent); XtDispatchEvent(&anEvent); } } InstallEventHandler(Widget topLevel) { Display *theDisplay = XtDisplay(topLevel); int connectNumber = ConnectionNumber(theDisplay); signal(SIGIO, XEventHandler); if (fcntl(connectionNumber, F_SETFL, FASYNC) < 0) { perror("Some error message"); return ERROR_OF_SOME_SORT; } if (fcntl(connectionNumber, F_SETOWN, getpid()) < 0) { perror("Some error message"); return ERROR_OF_SOME_SORT; } XFlush(theDisplay); return EVERTHING_WENT_OK; } Daniel daniel@cs.ualberta.ca