[comp.windows.x] question regarding exposure events in toolkit

dms@WHEATIES.AI.MIT.EDU (David M Siegel) (08/16/88)

I've written a simple toolkit application that uses a
simpleWidgetClass widget. I do raw X graphics operations to the
widget's window. I'm having trouble handling exposure events for the
window. Whenever the window gets any kind of real exposure event (that
is, some rectangle of the window has really changed) I want to redraw
the entire window (to keep things simple). Thus, it's necessary for
the exposure events to be "compressed". How does one go about doing
this? I've tried several schemes, including the following, which get
both multiple exposure events in some cases, and miss exposure events
altogether in other cases.

In main():

    XtAddEventHandler(simple, Expose, 1, do_expose, 0);

The handler:

do_expose(w, data, e)
Widget w;
char *data;
XEvent *e;
{
    XExposeEvent *event = (XExposeEvent *) e;

    if (event->count == 0) {
	do_display(last_x, last_y);
	XFlush(XtDisplay(simple));
    }
}

What's wrong with this?

Thanks!

-Dave

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (08/16/88)

    Date: Mon, 15 Aug 88 15:59:16 EDT
    From: dms@wheaties.ai.mit.edu (David M Siegel)

    Whenever the window gets any kind of real exposure event (that
    is, some rectangle of the window has really changed) I want to redraw
    the entire window (to keep things simple). Thus, it's necessary for
    the exposure events to be "compressed".

Register an ExposeProc for the widget, and set the widget's
compress_exposure field to TRUE.  The Intrinsics will compress multiple
exposures down into a single region for you, which you can either ignore
when redrawing the entire window, or which you can use as a clip-mask if
you choose.  See section 10.9.1 of the R2 Intrinsics manual.