Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-vax!josh From: josh@mit-vax.LCS.MIT.EDU (Joshua Marantz) Newsgroups: comp.windows.x Subject: Basic questions on X Toolkit Intrinsics Message-ID: <5119@mit-vax.LCS.MIT.EDU> Date: 20 Nov 88 22:56:57 GMT Organization: MIT LCS, Cambridge, MA Lines: 45 [Summary: I would like to call XtMainLoop recursively.] What are the best ways for a Toolkit client to query the user and wait for a response? I understand that this goes against the spirit of the toolkit, which is to have the program respond to the user rather than vice versa, but there are situations in which it is necessary: For example, an exceptional condition is discovered while processing a user request, such as "disk space full" or "out of memory" or "do you really want to delete all your files?". In most cases, it is possible to pop up widgets with callbacks to handle any of the possible responses, using the user-data-field to pass in some sort of context to continue processing in the appropriate manner. However, it is sometimes very difficult (in C) to encapsulate the entire execution context in a single data structure and restore it in the callback. It makes it difficult to use stack variables. In these cases, I would like to be able to pop up a widget and go into a recursive invocation of XtMainLoop (), which would return when the pop-up widget is unmapped, or when some routine like XtPopLevel is called. The only solution I can think of is to write my own main loop: int recursion_depth = 0; main_loop() { XEvent e; recursion_depth++; while (recursion_depth > 0) { XtNextEvent (&e); XtDispatchEvent (&e); } /* while */ } /* main_loop */ main_loop can be called recursively, provided XtDispatchEvent can. Is this legal? If it is, an application would "exit" by decrementing recursion_depth, rather than calling exit(). Is this the best way to prompt-and-block? Is there a danger of XtDispatchEvent finding a different widget set present after it calls the callbacks? Can this be handled by giving my main_loop some notion of a sub-tree of widgets that it can process? Joshua Marantz Viewlogic Systems, Inc.