home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!news.gtech.com!noc.near.net!gateway!miki!oj
- From: oj@miki.pictel.com (Oliver Jones)
- Subject: Re: Problems in X event handling
- Message-ID: <1992Aug26.115308.2412@miki.pictel.com>
- Organization: PictureTel Corporation
- References: <1992Aug19.063720.2994@ctr.columbia.edu>
- Date: Wed, 26 Aug 1992 11:53:08 GMT
- Lines: 59
-
- In article <1992Aug19.063720.2994@ctr.columbia.edu> raum@isoa3.ba.ttu.edu (Raum Pattikonda) writes:
- >During a display, a typical client program recognizes the "expose" event,
- >computes the data and sends for display to the X server.
-
- Actually, Expose events come in series. A well-written client
- recognizes and handles a whole series of Expose events. The "count"
- member of the Expose event's struct helps clients understand where
- each individual Expose event appears in its series.
-
- >For many
- >applications such as VLSI circuit layout, editing, construction
- >and display may take easily 2 to 3 minutes over a busy network.
-
- The long elapsed time probably has very little to do with network
- congestion, unless it's the application which is using NFS or
- some other network service to read large files.
-
- >Typically
- >the user resizes the window as soon as it appears. In such a case
- >the expose event is acknowledged two times and the image is displayed
- >two times... This problem can be
- >solved if the clients were written properly to handle asynchrounous
- >events or if Xlib has a watch dog to look for events asynchrounously
- >and take appropriate action.
-
- What you actually want to do is notice when the user has resized the
- window and abandon the ongoing redraw operation. Xlib provides very
- raw support for this, whereas Xt provides good support.
-
- What to do is this:
- (1) organize your program so the long-running (2-minute) redraw
- operation is carried out in a series of short (approx 50 millisecond)
- calls to an Xt work proc. (Work procs are called by the Xt main
- loop whenever there are no events or other inputs to handle).
- (2) write your Expose event handler so it uses XtAppAddWorkProc to
- register your work proc when it detects a series of Expose events.
- If the previous work proc is still active, your Expose handler
- should use XtRemoveWorkProc to remove it (this is the way you
- abandon the redrawing for obsolete Expose events).
- (3) set the drawing window's bit_gravity to ForgetGravity. That
- way X will clear the entire window and send an Expose series
- when the user resizes it.
-
- The tricky part of this suggestion is part 1, because it means you
- must reorganize your redraw operation from a single loop to a series
- of calls to a subroutine.
-
- Many refinements to this basic method are possible, to improve the
- application's performance when Expose event series result from
- operations other than the user resizing the window.
-
- >In our example the the watch dog will
- >peek and detect the second expose event before the action is taken for
- >first expose event and will make client discard the first expose event.
-
- This probably doesn't help much unless you repeatedly look ahead for
- subsequent Expose events as your drawing progresses.
-
- Oliver Jones
-