4 * Contains commands for Xt notifier specific tests on Unix.
6 * Copyright (c) 1997 by Sun Microsystems, Inc.
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 # define USE_TCL_STUBS
15 #include <X11/Intrinsic.h>
18 static Tcl_ObjCmdProc TesteventloopCmd;
21 * Functions defined in tclXtNotify.c for use by users of the Xt Notifier:
24 extern void InitNotifier(void);
25 extern XtAppContext TclSetAppContext(XtAppContext ctx);
28 *----------------------------------------------------------------------
32 * This procedure performs application-specific initialization. Most
33 * applications, especially those that incorporate additional packages,
34 * will have their own version of this procedure.
37 * Returns a standard Tcl completion code, and leaves an error message in
38 * the interp's result if an error occurs.
41 * Depends on the startup script.
43 *----------------------------------------------------------------------
48 Tcl_Interp *interp) /* Interpreter for application. */
50 if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
53 XtToolkitInitialize();
55 Tcl_CreateObjCommand(interp, "testeventloop", TesteventloopCmd,
61 *----------------------------------------------------------------------
65 * This procedure implements the "testeventloop" command. It is used to
66 * test the Tcl notifier from an "external" event loop (i.e. not
70 * A standard Tcl result.
75 *----------------------------------------------------------------------
80 ClientData clientData, /* Not used. */
81 Tcl_Interp *interp, /* Current interpreter. */
82 int objc, /* Number of arguments. */
83 Tcl_Obj *const objv[]) /* Argument objects. */
85 static int *framePtr = NULL;/* Pointer to integer on stack frame of
86 * innermost invocation of the "wait"
90 Tcl_WrongNumArgs(interp, 1, objv, "option ...");
93 if (strcmp(Tcl_GetString(objv[1]), "done") == 0) {
95 } else if (strcmp(Tcl_GetString(objv[1]), "wait") == 0) {
98 int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
101 * Save the old stack frame pointer and set up the current frame.
104 oldFramePtr = framePtr;
108 * Enter an Xt event loop until the flag changes. Note that we do not
109 * explicitly call Tcl_ServiceEvent().
114 XtAppProcessEvent(TclSetAppContext(NULL), XtIMAll);
116 (void) Tcl_SetServiceMode(oldMode);
117 framePtr = oldFramePtr;
119 Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]),
120 "\": must be done or wait", NULL);