[comp.windows.x] breaking out of XtMainLoop

cso@organ.cis.ohio-state.edu (Conleth OConnell) (04/19/89)

Someone else must have wanted to do this, so pleeeease give me a clue
because at the moment I am without one!  I am trying to keep at the X
Toolkit level, without trying to rewrite a main loop or use too many
Xlib routines.

I have a callback defined for a list widget to set a global variable
to the index in the list that was selected.  Now that I have obtained
a value, I want to exit the Mainloop, without destroying the windows,
so that I can change the list and restart the mainloop.  I feel like I
should be able to do this but how is not clear to me...

Cheers and Thanks,
Con O'Connell

-=-
Conleth S. O'Connell	Department of Computer and Information Science
cso@cis.ohio-state.edu		 The Ohio State University
				       2036 Neil Ave.
				Columbus, OH USA 43210-1277

cso@organ.cis.ohio-state.edu (Conleth OConnell) (04/19/89)

I seem to have found what I was looking for, after reading deeper into
the FM :-)  Basically, using the XtAppMainLoop and fixing it to check
to see if my variable had been modified and exiting...how much simpler
can I get!!  ;-)

Sorry for the naive question!
Con
-=-
Conleth S. O'Connell	Department of Computer and Information Science
cso@cis.ohio-state.edu		 The Ohio State University
				       2036 Neil Ave.
				Columbus, OH USA 43210-1277

asente@decwrl.dec.com (Paul Asente) (04/19/89)

In article <44097@tut.cis.ohio-state.edu> <cso@cis.ohio-state.edu> writes:
>Someone else must have wanted to do this, so pleeeease give me a clue
>because at the moment I am without one!  I am trying to keep at the X
>Toolkit level, without trying to rewrite a main loop or use too many
>Xlib routines.

Don't be afraid to write your own main loop!  XtAppMainLoop is just intended
as a convenience.  Here's the code:

void XtAppMainLoop(app)
        XtAppContext app;
{
    XEvent event;

    for (;;) {
        XtAppNextEvent(app, &event);
        XtDispatchEvent(&event);
    }
}

As you can see, it only uses public interfaces.  You can use XtNextEvent
instead of XtAppNextEvent if you are using the default application context.

	-paul asente
	    asente@decwrl.dec.com	decwrl!asente

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (04/20/89)

>  Now that I have obtained
> a value, I want to exit the Mainloop, without destroying the windows,
> so that I can change the list and restart the mainloop. 

Paul has explained how to code your own XtMainLoop() and this is certainly
a valid thing to do.  My question is why not just change your list in the
callback proceedure?  I have been writing toolkit programs for almost 
2 years now, and have only once had to code my own XtMainLoop().  I guess
this is just a general caution to all you toolkit developers out there to
look before you leap.  Please take a minute to try to work within the
framework provided before you dive into building your own Event Dispatcher.


                                                Chris D. Peterson
                                                MIT X Consortium