[comp.windows.x] More sophisticated XtMainLoop

kap121@ztivax.UUCP (Thomas Oeser) (01/25/89)

I am going to implement a X client that itself acts as a server for another
(graphics) application. The server handles both preparing high level imaging
instructions for output into a (sub-)window as well as pre-processing `raw' 
input information (e.g. converting pointer values into ids of picked drawable
objects). The interface for the user interaction should be built using widgets.

In this context it turns out, that the server should listen in paralell to

	- events produced by the X server (and handled via XtMainLoop, 
	widgets, etc.);

	- `events' generated by incoming protocol elements from its client(s)
	forcing the server to perfom some actions.

    NOTE, some other requirements force me, to both hande user input
    asynchroneously and synchroneously (as required by the client application of
    the server).

Now the common scheme of programs using widgets is:

	main (...)
	  {
	      /*...*/

	      toplevel = XtInitialize(...);

	      /*...*/

	      XtRealizeWidget(toplevel);
	      XtMainLoop(); /*Exit from XtMainLoop and from main */
			    /*via a callback			 */
	  }


A very raw approach of my program scheme is:

	#define EVER ;;

	main (...)
	  {
	      /*...*/

	      toplevel = XtInitialize(...);

	      /*...*/

	      XtRealizeWidget(toplevel);
	      for( EVER )/* Exit from this loop and from main via */
			 /* processX_Event() or doSomethingElse() */
		{
		    if( nothingElseToDo || thereIsA_X_Event )
		        processX_Event(...);
		    else
			doSomethingElse(...);
		}
	  }


When refining this scheme it will turn out that the number of realized and/or
managed widgets will change both on X events or on incoming protocol events.

Anyway, is there already an appropriate mechanism to hang in user (i.e. other
than X events) into the cycle of XtMainLoop() in order to get
"doSomethingElse() called as a callback?

Another thing, that causes me headache, is that I want (must?) interrupt or
disable XtMainLoop() after some user interactions and continue to process
exclusively incoming protocol packages. I.e., to mask X events for some times.

Any help or solution for this?

Thomas Oeser

------------------------------------------------------------------------------
ARPA:		kap121@ztivax.siemens.com
UUCP:		kap121@ztivax.uucp (may work only in Europe...)
Postal mail:	Siemens AG, K Sys Ap 121, Otto-Hahn-Ring 6, P.O. Box 830951,
		D-8000 Munich 83, West Germany
Phone:		+ 49 (89) 636-47537
FAX:		+ 49 (89) 636-41477

Disclaimer:
The opinions expressed are my own, and should not be attributed to anyone else
living or dead.
------------------------------------------------------------------------------