#include "src/rplexternals.h" #include "motif.h" declareExternalFunction(XtAppMainLoop) XEvent event; declareObject(appObject); HEADER declareHelpString("Main loop of a Motif application\n" " 1: AppContext\n"); numberOfArguments(1); FUNCTION if (initializationDone eq true) then pullFromStack(appObject, external); returnOnError(freeObject(appObject)); ifIsExternal(appObject, APPCONTEXT) then orElse executionError("Type mismatch"); returnOnError(freeObject(appObject)); endIf intrinsic(pshcntxt); doUntil if (XtAppPending(target(objectContainer(sXtAppContext, appObject)).context) ne 0) then XtAppNextEvent(target(objectContainer(sXtAppContext, appObject)).context, &event); if (event.type eq DestroyNotify) then if (event.xdestroywindow.window eq XtWindow(target(objectContainer(sXtAppContext, appObject)).widget)) then XtAppSetExitFlag(target(objectContainer( sXtAppContext, appObject)).context); endIf endIf XtDispatchEvent(&event); orElse pollSignalsAndInterrupts(); usleep(10000); endIf repeatUntil(XtAppGetExitFlag(target( objectContainer(sXtAppContext, appObject)).context) or (stopRequest eq -1) or (exitMainLoop ne 0)) intrinsic(pulcntxt); XtDestroyApplicationContext(target( objectContainer(sXtAppContext, appObject)).context); orElse executionError("Application not initialized"); returnOnError(); endIf setFalse(initializationDone); END endExternalFunction // vim: ts=4