Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ AppMainLoop(3X) — DeltaWindows 1.3.3 Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

 

NAME

XtAppMainLoop − continuously process events. 

SYNOPSIS

void XtAppMainLoop(app_context)
    XtAppContext app_context;

Inputs

app_context
Specifies the application context that identifies the application.

Returns

XtAppMainLoop() enters an infinite loop and never returns. 

DESCRIPTION

XtAppMainLoop() enters an infinite loop which calls XtAppNextEvent() to wait for an events on all displays in app_context and XtDispatchEvent() to dispatch that event to the appropriate code. 

USAGE

Most applications will call XtAppNextEvent() as the last line of their main() procedure.  Some applications may provide their own versions of this loop, however.  A custom event loop might test an application-dependent global flag or other termination condition before looping back and calling XtAppNextEvent().  If the number of top-level widgets drops to zero, the application may be able to exit safely, for example. 

Applications that use multiple application contexts or that use internal event loops will have to build their own event loop. 

BACKGROUND

XtAppNextEvent() looks for X events in the input queue, and also handles timer events (see XtAppAddTimeOut()) and events from alternate input sources (see XtAppAddInput()).  If none of these events are pending and a work procedure (see XtAppAddWorkProc()) is registered, XtAppNextEvent() invokes that work procedure to do background processing, otherwise it blocks waiting for an event.  Note that XtAppNextEvent() dispatches timer and input events directly, but returns any X events that occur.  Within XtAppMainLoop(), these X events are always passed to XtDispatchEvent(). 

XtDispatchEvent() dispatches an event to the appropriate event handlers (see XtAddEventHandler()).  Note that the translation manager registers an event handler, and that events that are dispatched to the translation manager will be further dispatched through the translations-to-actions mechanism. 

EXAMPLE

XtAppMainLoop() is implemented as follows: void XtAppMainLoop(app)
        XtAppContext app; {
    XEvent event;
 
    for (;;) {
        XtAppNextEvent(app, &event);
        XtDispatchEvent(&event);
    } }

SEE ALSO

XtAddEventHandlerUNIX SYSTEM V/68, XtAppAddInputUNIX SYSTEM V/68, XtAppAddTimeOutUNIX SYSTEM V/68, XtAppAddWorkProcUNIX SYSTEM V/68, XtAppNextEventUNIX SYSTEM V/68, XtAppProcessEventUNIX SYSTEM V/68, XtDispatchEventUNIX SYSTEM V/68. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026