Overview
| Artifact ID: | 76d3e3fb27fb05bd53514b09a6e7eebf28cea7b7 |
|---|---|
| Ticket: | 1038760fffffffffffffffffffffffffffffffff |
| Date: | 2004-10-02 05:35:28 |
| User: | nirajvdesai |
| Artifact Attached: | 4f95a99dc12142553d0f8f96d7e230aee923755b |
| Filename: | main.c |
| Description: | main.c file for simulating c-Tcl interface showing Tcl_DoOneEvent problem. |
Content:
/* main.c for event loop testing */
#include <stdio.h>
#include <tk.h>
#include <unistd.h>
/* compile with:
gcc -o tclmodal main.c -ltcl8.4 -ltk8.4
*/
static Tcl_Interp *interp;
int TclIsRunning;
void tkexit(void *d, XEvent *eventPtr)
{
if (eventPtr->type == DestroyNotify) {
Tcl_DeleteInterp(interp);
TclIsRunning = 0;
}
}
int main(int argc, char *argv[])
{
const char *exePath_;
Tcl_FindExecutable(exePath_);
interp = Tcl_CreateInterp();
Tcl_Init(interp);
Tk_Init(interp);
Tk_Window nw;
nw = Tk_MainWindow(interp);
Tk_CreateEventHandler(nw, StructureNotifyMask, tkexit, 0);
Tcl_EvalFile(interp, "modaldlg.tcl");
TclIsRunning = 1;
while (TclIsRunning) {
while (Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT));
printf("Returned from Tcl_DoOneEvent ");
usleep(10);
}
printf("Exiting\n");
return 0;
}
