I'm trying to combine a tcl/tk program with another X app. For this a
choose to write my
own main loop to get events from the other app. for catching tcl events
I use Tcl_DoOneEvent() which works sort of if I set it to non-blocking.
Here's my main loop:
XEvent ev;
for(;;){
if(XtAppPending(appCon)){ // is there an X event waiting ?
XtAppNextEvent(appCon, &ev); // yes, process it
XtDispatchEvent(&ev);
}
else {
// process any tcl event but do not block !
Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS);
}
}
Right now the tk part is real simple, just 3 buttons. Problem is, when I
press
a tk button nothing happens until I put my mouse over the other app. SO
that's a complete showstopper for a GUI ! I've tried using other
constants the ALL_EVENTS but luck. I am running tcl/tk 8.00 is that to
"old"/buggy ?
Anybody have any advice how to nail down what is going wrong. I guess I
could always
write my own version of Tcl_DoOneEvent() ....
Thanks for and help you might provide !
Chris
--
Chris Harding - Virtual Environment Technology Laboratory
University of Houston, Houston, TX 77204-0903
Voice: (713) 743 1284 Fax: (713) 743 11 98
email: ch...@metropolis.vetl.uh.edu http://www.vetl.uh.edu/~chris/
Just wondering...
Marco
In article <37278FF6...@metropolis.vetl.uh.edu>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
> XEvent ev;
> for(;;){
> if(XtAppPending(appCon)){ // is there an X event waiting ?
> XtAppNextEvent(appCon, &ev); // yes, process it
> XtDispatchEvent(&ev);
> }
> else {
> // process any tcl event but do not block !
> Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS);
> }
> }
> Anybody have any advice how to nail down what is going wrong. I guess I
> could always
> write my own version of Tcl_DoOneEvent() ....
The problem here is that XtAppPending doesn't know anything about Tk's
connection to the X server, so it isn't waking up when events happen on the Tk
side. You need to use the Xt based notifier. You can replace
unix/tclUnixNotfy.c with unix/tclXtNotify.c when you build Tcl. Also, take a
look at tclXtTest.c for an example of how to construct an Xt based event loop.
___________________________________________________________
Scott Stanton 650-210-0105 tel
Sr. Software Engineer 650-210-0101 fax
Scriptics Corporation scott....@scriptics.com
The Tcl Platform Company http://www.scriptics.com
Good luck,
Marco
In article <3729D28C...@metropolis.vetl.uh.edu>,
Chris Harding <ch...@metropolis.vetl.uh.edu> wrote:
> You mean defining the X part as an Idle event and use TkMainLoop() ?
> >
> > Wouldn't it be easier (and more straightforward) to define your event loop
as
> > an additional event source for the Tk event handler?
> >
> > Just wondering...
> >
> > Marco
> >
> > In article <37278FF6...@metropolis.vetl.uh.edu>,
> > Chris Harding <ch...@metropolis.vetl.uh.edu> wrote:
> > > Hi,
> > >
> > > I'm trying to combine a tcl/tk program with another X app. For this a
> > > choose to write my
> > > own main loop to get events from the other app. for catching tcl events
> > > I use Tcl_DoOneEvent() which works sort of if I set it to non-blocking.
> > > Here's my main loop:
> > >
> > > XEvent ev;
> > > for(;;){
> > > if(XtAppPending(appCon)){ // is there an X event waiting ?
> > > XtAppNextEvent(appCon, &ev); // yes, process it
> > > XtDispatchEvent(&ev);
> > > }
> > > else {
> > > // process any tcl event but do not block !
> > > Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS);
> > > }
> > > }
> > >
> > > Right now the tk part is real simple, just 3 buttons. Problem is, when I
> > > press
> > > a tk button nothing happens until I put my mouse over the other app. SO
> > > that's a complete showstopper for a GUI ! I've tried using other
> > > constants the ALL_EVENTS but luck. I am running tcl/tk 8.00 is that to
> > > "old"/buggy ?
> > >
> > > Anybody have any advice how to nail down what is going wrong. I guess I
> > > could always
> > > write my own version of Tcl_DoOneEvent() ....
> > >
I remeber now (tried it again) - it works only once ! So unless somebody
know how I can
define a callback, that is called over and over again, I'm back with my
old plan (i.e. my own loop). So, is the a way to say "Whenever, you are
idle do this again and again" ?
Cheers
Chris
Can you give us any more information? I tried to 'make xttest' in a fresh 8.1
directory but it get (Linux, redhat 5.2)...
xtTestInit.o: In function `Tcl_AppInit':
xtTestInit.o(.text+0xc3): undefined reference to `Procbodytest_Init'
xtTestInit.o(.text+0xd1): undefined reference to `Procbodytest_SafeInit'
xtTestInit.o(.text+0xd7): undefined reference to `Procbodytest_Init'
-John
Scott Stanton wrote:
> Chris Harding wrote:
>
> > XEvent ev;
> > for(;;){
> > if(XtAppPending(appCon)){ // is there an X event waiting ?
> > XtAppNextEvent(appCon, &ev); // yes, process it
> > XtDispatchEvent(&ev);
> > }
> > else {
> > // process any tcl event but do not block !
> > Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS);
> > }
> > }
>
> > Anybody have any advice how to nail down what is going wrong. I guess I
> > could always
> > write my own version of Tcl_DoOneEvent() ....
>
proc event_handler {} {
global whatever
do_something
after $whatever event_handler
}
set whatever 1000
after $whatever event_handler
The C case is analogous (and you seem definitely more than capable of figuring
it out yourself :] )
Bye,
Marco
In article <372E21AB...@metropolis.vetl.uh.edu>,
> > > > > XEvent ev;
> > > > > for(;;){
> > > > > if(XtAppPending(appCon)){ // is there an X event waiting
?
> > > > > XtAppNextEvent(appCon, &ev); // yes, process it
> > > > > XtDispatchEvent(&ev);
> > > > > }
> > > > > else {
> > > > > // process any tcl event but do not block !
> > > > > Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS);
> > > > > }
> > > > > }
> > > > >
> > > > > Right now the tk part is real simple, just 3 buttons. Problem is, when
I
> > > > > press
> > > > > a tk button nothing happens until I put my mouse over the other app.
SO
> > > > > that's a complete showstopper for a GUI ! I've tried using other
> > > > > constants the ALL_EVENTS but luck. I am running tcl/tk 8.00 is that to
> > > > > "old"/buggy ?
> > > > >
> > > > > Anybody have any advice how to nail down what is going wrong. I guess
I
> > > > > could always
> > > > > write my own version of Tcl_DoOneEvent() ....
> > > > >
It looks like this code has suffered bit rot since 8.0. I don't have a working
implementation for 8.1 at this time, but it shouldn't be too difficult to
extrapolate from the 8.0 version. If someone is interested in updating this
code and submitting a patch, I can try to get it into the next release.