[comp.windows.x] Nested XtMainLoop

merlyn@attunix.att.COM (05/05/90)

[ I'm submitting this message on behalf of one of our customers
  who does not have access to the xpert mailing list. However, I
  will gladly field responses, comments, questions, etc.

	-Steve Humphrey, AT&T, merlyn@attunix.att.com ]

We are designing a C++ toolkit for building dialog boxes. All
dialog boxes are modal to our application. Therefore, while a
dialog box is showing, no user input will go to other parts of
the application. This allows a toolkit designed so that
application code uses a particular dialog box by sending it the
Show() message, and the message returns after the user
dismisses the dialog box. Application code immediately
following the show() can respond to whatever the user has
input. Show() invokes a procedure containing an event loop that
calls XtProcessEvent(XtIMAll) until dismissal.

We are seeking advice in order to determine the safest way to
implement a modal cascade of dialog boxes. Some user input to
some dialog box causes a second dialog box to pop up over the
first. Since we are forming a modal cascade, the most recent
dialog box is uppermost, and only it gets user input. So the
user can only dismiss the most recent dialog box. Notice that
the code that shows the second dialog box is invoked while the
first dialog box is showing. This means that the Show() method
of the second dialog box is ``nested'' within the Show() method
of the first. That is, Show() is called recursively.

It is possible for us to implement our toolkit so that we do
not call XtProcessEvent(XtIMAll) recursively. Our question
is: Is it necessary? Should we put in the extra programming
effort (and the extra code) to avoid the recursive calls? I
have never seen Xt documentation directly address this
issue. Does anyone have advice?

A test program that works has an event loop built from
XtNextEvent and XtDispatchEvent nested within an
XtCallbackProc that is called-back from a widget. This indicates
that at least XtDispatchEvent can be called recursively.
But is this an ``undocumented feature'' that might disappear in
the future? Our applications will be using XtAddInput and
XtAddTimeOut, which might introduce complications. We may also
want to use XtAddWorkProc in the future.