[comp.windows.x] Help Sending Events within an application

cohnr@kira.msu.edu (Richard Cohn) (05/23/91)

I'm trying to simulate an expose event within my application using 
XtDispatchEvent.  I send the event to my toplevel window using the routine
at the end of this message.  The status flag sent returned from
XtDisplatchEvent does register that the event has been sent.

Unfortunately, the event never reaches the expose method of the widget I use
to handle drawing to the screen and several other miscelaneous events.  When I
"manually" generate the expose event by covering the application window with
another and then removing the other window, my widget does receive the expose
event and proceeds to redraw the screen.

Any help anyone can give will be most appreciated. 

BTW--I'm running X11R4 on both a Sun and an HP9000 workstation.  My application
uses Xlib, Xtm, and the Athena Widgets.

/*  SendRedraw >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
 *
 *  Purpose:  Sends an expose event to the screen so it can be redrawn.
 *
 */

void SendRedraw()

/*****************************************************************************/

{
	extern Widget toplevel;
	Display *display;
	Window window;
	XEvent event;
	Arg args[5];
	int i, width, height;
	int st;

/*  Get display and window information about the toplevel window  */

	display= XtDisplay(Drawspace);
	window= XtWindow(Drawspace);

/*  Find height and width of the window, we'll expose the whole thing for now */

	i= 0;
	XtSetArg(args[i], XtNheight, &height); i++;
	XtSetArg(args[i], XtNwidth, &width); i++;
	XtGetValues(toplevel, args, i);

/*  Develop the expose event  */

	event.xexpose.type= Expose;
	event.xexpose.display= display;
	event.xexpose.window= window;
	event.xexpose.x= 0;
	event.xexpose.y= 0;
	event.xexpose.width= width;
	event.xexpose.height= height;
	event.xexpose.send_event= TRUE;

	st= XtDispatchEvent(&event);

	if (st == 0)
	{
		printf("Send Event Failed\n");
	}
	else
	{
		printf("Event away\n");
	}

	return;
}

/*  End of Graph3.c  */