[comp.windows.x.motif] XmNexposeCallback -- How do I send my own?

CWIKLA@uimrl7.mrl.uiuc.edu (John/Consultant) (04/29/91)

	I basically have a drawingarea widget that at some point I need
the whole thing redrawn.  I have it set up so that it accepts exposure
events and then redraws itself (I have it so it only redraws what it needs
to...)...Basically I am looking for a way to send a ReFresh to my widget
or an Exposure of the entire drawingarea widget....Is this possible with
XSendEvent -- if so, then how?

Thanks in advance.




******************************************************************************
*  John L. Cwikla             *   cwikla@uiucmrl, cwikla@uimrl7.mrl.uiuc.edu *
*  Chief Consultant, MRLCFC   *	  uimrl::cwikla		(217)333-8281        *
*  University of Illinois     *   Redefining Lunacy...			     *
******************************************************************************

rthomson@mesa.dsd.es.com (Rich Thomson) (04/29/91)

In article <1991Apr29.025823.7094@ux1.cso.uiuc.edu>
	CWIKLA@uimrl7.mrl.uiuc.edu (John/Consultant) writes:
>	I basically have a drawingarea widget that at some point I need
>the whole thing redrawn.

Try the following piece of code:

    Widget da;
    XmDrawingAreaCallbackStruct da_struct;

    da_struct.reason = XmCR_EXPOSE;
    da_struct.event = (XEvent *) NULL;
    da_struct.window = XtWindow(da);

    XtCallCallbacks(da, XmNexposeCallback, (XtPointer) da_struct);

If some cosmological aligning of the planets prevents this from
working, try:

    XClearArea(XtDisplay(da), XtWindow(da), 0, 0, 0, 0, True);

This will clear your window and generate an expose event.  The first solution
looks more complicated, but is really preferred because it doesn't
actually require a round trip to the server as in the second example.
The round trip happens because you request the clear, then receive the
expose event from the server, while the first doesn't have to wait for
the expose event to arrive before it starts redrawing.  Alternatively,
if you neeed the window cleared, but don't want to wait for the expose
event, set the last parameter to False in the XClearArea call (or use
XClearWindow).

							-- Rich
-- 
  ``Read my MIPS -- no new VAXes!!'' -- George Bush after sniffing freon
	    Disclaimer: I speak for myself, except as noted.
UUCP: ...!uunet!dsd.es.com!rthomson		Rich Thomson
ARPA: rthomson@dsd.es.com			PEXt Programmer

cjmchale@cs.tcd.ie (Ciaran McHale) (04/29/91)

In <1991Apr29.040007.11132@dsd.es.com>
rthomson@mesa.dsd.es.com (Rich Thomson) writes:

>In article <1991Apr29.025823.7094@ux1.cso.uiuc.edu>
>	CWIKLA@uimrl7.mrl.uiuc.edu (John/Consultant) writes:
>>	I basically have a drawingarea widget that at some point I need
>>the whole thing redrawn.
>
>Try the following piece of code:
>    [...]
>    XtCallCallbacks(da, XmNexposeCallback, (XtPointer) da_struct);
>
>If some cosmological aligning of the planets prevents this from
>working, try:
>
>    XClearArea(XtDisplay(da), XtWindow(da), 0, 0, 0, 0, True);
>
>This will clear your window and generate an expose event.  The first solution
>looks more complicated, but is really preferred because it doesn't
>actually require a round trip to the server as in the second example.
>The round trip happens because you request the clear, then receive the
>expose event from the server, while the first doesn't have to wait for
>the expose event to arrive before it starts redrawing.  Alternatively,
>if you neeed the window cleared, but don't want to wait for the expose
>event, set the last parameter to False in the XClearArea call (or use
>XClearWindow).

Another handy way to "send" an event to your own application is to set
up the event structure as you would for XSendEvent() but rather than
call XSendEvent(), just call XtDispatchEvent() instead. Like above,
this avoids the round trip to the server. You can use XClearWindow() or
XClearArea(..., False) to clear the window first, if desired.


Ciaran.
-- 
Ciaran McHale      "I have some faults, but modesty isn't one of them."  ----
Department of Computer Science, Trinity College, Dublin 2, Ireland.      \  /
Telephone: +353-1-772941 ext 1538       FAX: +353-1-772204                \/
Telex: 93782 TCD EI                     email: cjmchale@cs.tcd.ie