[comp.windows.x] Soliciting XEvents and user inputs simultaneously...QUESTION

narayan@cs.iastate.edu (Pankaj Narayan) (03/22/90)

I have an application where I need to draw contour levels on the
screen, and keep doing that till the user runs out of data....i.e,
have to keep soliciting user input till he hits a -1 or some such
sentinel value. 

At the same time, one needs to constantly keep watch on the different
events that X generates, incase the window gets resized etc.

One naive way to do this would be to simply loop, once having called
the contour-drawing routine, but this would mean that XNextEvent() is
never solicited, since control is never returned to the bigger
while(1) loop.

What I came up with is also faulty, but will let me do things a little
better:

	while (level != 0) {     /* replace the while(1) */
	  XGetEvent(&event);
	  switch(event.type) {
		case Exposure:
		   draw_contour(level);
	           break;
		case Resize:
		   do some processing....

		default:
		   break;
	  } /* of switch */
	
          printf("please input next level for which contour is to be
	          drawn, indicate stop with '0'");
	  scanf (&level);
	} /* of while() */

The problem here, as is easily seen, is that should a user go to sleep
and the window in which the contour is being drawn should get resized
etc, the application will never get those events till the user comes
out of his coma and supplies a 'level' value (unblocking the 'scanf'
call). 

I'm sure there is a more advanced way to do this, but don't know what
it is. 

The printf and scanf are being done in the parent window (i.e. where
this application is invoked from). 


Any pointers, anyone....... ???
	 
************************************************************************* 
Pankaj Narayan                           narayan@atanasoff.cs.iastate.edu
246 North Hyland Ave, Apt. 306 ,Ames, IA 50010  Ph: (515) 292-5535
*************************************************************************

--
Pankaj Narayan                           narayan@atanasoff.cs.iastate.edu
246 North Hyland Ave, Apt. 306 ,Ames, IA 50010  Ph: (515) 292-5535