Mixing Xevents and Tcl/Tk events with tcl/tk version 8.0/8.2 
Author Message
 Mixing Xevents and Tcl/Tk events with tcl/tk version 8.0/8.2

Hi!

Does anybody have an example on how to mix X events with Tcl/Tk events
with
tcl/tk version 8.0 or 8.2 ?

The following code extracted from some FAQ does not compile under
8.0 and 8.2.

Thanks,
Jean-Pierre


void XtEventSetup(ClientData xtconn, int flags)
     {
       static Tcl_Time maxDelay={0, 300000}; /* To process non-X events
*/

       Tcl_WatchFile((Tcl_File)xtconn, TCL_READABLE);
       Tcl_SetMaxBlockTime(&maxDelay);
     }

     int XtDoEvent(Tcl_Event *evPtr, int flags)
     {
       while (XtPending())
         XtProcessEvent(XtIMAll);
       return 1;
     }

     void XtEventCheck(ClientData xtconn, int flags)
     {
       Tcl_Event *event;

       if(XtPending()) {
         event       = (Tcl_Event *)ckalloc(sizeof(Tcl_Event));
         event->proc = XtDoEvent;
         Tcl_QueueEvent(event, TCL_QUEUE_TAIL);
       }
     }

     void tkGo (void)
     {
       extern Widget topLevel;
       Tcl_File xtconn;
       int xtfd = ConnectionNumber(XtDisplay(topLevel));

       xtconn = Tcl_GetFile((ClientData)xtfd, TCL_UNIX_FD);

       Tcl_CreateEventSource(XtEventSetup, XtEventCheck,
(ClientData)xtconn);
       while (1) {
         Tcl_DoOneEvent(TCL_ALL_EVENTS);
       }
     }

--
Jean-Pierre Belanger, OSim Product Development Manager
OriginalSim  - Framework for building distributed simulations.
Tel: 514-766-8868 Ex:28, Fax: 514-766-8861



Fri, 15 Feb 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VERSION CONTROL: Tcl/Tk version 8.2 ???

2. Different window behavior in Tcl/Tk 8.0 and 8.2

3. tcl 8.2 and tk 8.2 do not compile on SunOS 4.1.4 using cc(1)

4. for > tcl/tk 8.2 (tcl/tk8.3)

5. tcl/tk 8.0 problem with Windows app that calls tcl/tk script

6. Tcl-DP requires Tcl 8.0 not 8.2?

7. Combine Tcl/Tk/Tix (8.0) and Xt/Motif event handling

8. Tcl/Tk 8.2

9. Any trouble with Tcl/Tk 8.2 ?

10. tk 8.0 -> 8.2 text problems (unicode)

11. DEC 64bit platform and Tcl/Tk 8.2 problem !?!

12. Pipe deadlock in Tcl/Tk 8.2

 

 
Powered by phpBB® Forum Software