Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Creating event sources
Hi,

I have tried to get an extension to create an event
source and get the event loop to drive the action.

It kind of works but when I do this:

$ /usr/local/bin/wish8.4
% source sample.tcl

I can see that the event source is created but nothing
happens until I move the mouse over the wish window,
likewise if I use tclsh8.4, after the event source
is created nothing seems to happen.

Is that normal or do I need to do something to boot the
event loop?

Thanks,
Andres

P.S. Please excuse me if these question ends up appearing
several times, my news server seems to be acting up.

Report this thread to moderator Post Follow-up to this message
Old Post
Andres Garcia
08-21-04 01:56 AM


Re: Creating event sources
Andres Garcia wrote:

> Hi,
>
> I have tried to get an extension to create an event
> source and get the event loop to drive the action.
>
> It kind of works but when I do this:
>
> $ /usr/local/bin/wish8.4
> % source sample.tcl
>
> I can see that the event source is created but nothing
> happens until I move the mouse over the wish window,
> likewise if I use tclsh8.4, after the event source
> is created nothing seems to happen.
>
> Is that normal or do I need to do something to boot the
> event loop?
>

When you run wish an event loop is automatically started; when you run
tclsh it is not. Does that answer your question?


Report this thread to moderator Post Follow-up to this message
Old Post
Bryan Oakley
08-21-04 01:56 AM


Re: Creating event sources
Hi,

> When you run wish an event loop is automatically started; when you run
> tclsh it is not. Does that answer your question?

Not really, if the loop is automatically started in wish, why doesn't
anything happen until I move the mouse over the wish window?

Andres

Report this thread to moderator Post Follow-up to this message
Old Post
Andres Garcia
08-23-04 01:58 PM


Re: Creating event sources
Andres Garcia wrote:

> Hi,
>
> 
>
>
> Not really, if the loop is automatically started in wish, why doesn't
> anything happen until I move the mouse over the wish window?

I'd have to have more specifics to answer that. Can you post a small
block of code that illustrates the problem? Also, what platform is this
one? Is it possible you have a window manager that is configured to
suspend windows that aren't in the foreground?


Report this thread to moderator Post Follow-up to this message
Old Post
Bryan Oakley
08-23-04 09:01 PM


Re: Creating event sources
Hi,

> I'd have to have more specifics to answer that. Can you post a small
> block of code that illustrates the problem? Also, what platform is this
> one? Is it possible you have a window manager that is configured to
> suspend windows that aren't in the foreground?

The platform is Mandrake 10 with Kde, but I have tried with Gnome
and the same thing happens, the events are only triggered while am
I moving the mouse over the wish window, even though it is not the
selected window.

The code I am using to create the event source,after removing the
specifics of what it does, is the following:

int
InitSource(Tcl_Interp *interp, struct myData *myDataPtr,
int objc,Tcl_Obj *CONST objv[]) {

 Tcl_CreateEventSource((Tcl_EventSetupPro
c *)NULL,
(Tcl_EventCheckProc *)EventCheck, (ClientData *)myDataPtr);

return TCL_OK;
}

void
EventCheck(ClientData clientData, int flags) {
struct curlMultiObjData    *curlMultiData=
(struct curlMultiObjData *)clientData;
Tcl_Event                  *eventToInvokePtr;
struct curlEvent           *curlEventPtr;
int                         selectCode;

 selectCode=CheckIfSomethingToDo(myDataPt
r);

if (myDataPtr->running==0) {
 Tcl_DeleteEventSource((Tcl_EventSetupPro
c *)NULL,
(Tcl_EventCheckProc *)curlEventCheck,
(ClientData *)curlMultiData);
} else {
if (selectCode>=0) {
EventPtr=(struct Event *)Tcl_Alloc(sizeof(struct Event));
EventPtr->proc=EventProc;
EventPtr->myDataPtr=myDataPtr;
Tcl_QueueEvent((Tcl_Event *)EventPtr, TCL_QUEUE_TAIL);
}
}
}

int
EventProc(Tcl_Event *evPtr,int flags) {
struct myData   *myDataPtr=(struct myData *)
((struct Event *)evPtr)->myDataPtr;
DoSomething(myDataPtr);
return 1;
}

Thanks for your help,
Andres

Report this thread to moderator Post Follow-up to this message
Old Post
Andres Garcia
08-25-04 04:06 AM


Re: Creating event sources
Andres Garcia wrote:

> Hi,
>
> 
>
>
> The platform is Mandrake 10 with Kde, but I have tried with Gnome
> and the same thing happens, the events are only triggered while am
> I moving the mouse over the wish window, even though it is not the
> selected window.
>
> The code I am using to create the event source,after removing the
> specifics of what it does, is the following:
>
> int
> InitSource(Tcl_Interp *interp, struct myData *myDataPtr,
>         int objc,Tcl_Obj *CONST objv[]) {
>

We're suddenly out of my depth; I was hoping maybe the problem lay at
the tcl level. Apparently not, and I'm not familiar with the internals.
Sorry I can't be of more help.

Report this thread to moderator Post Follow-up to this message
Old Post
Bryan Oakley
08-25-04 04:06 AM


Re: Creating event sources
Hello,

Andres Garcia wrote:
> Hi,
>
> I have tried to get an extension to create an event
> source and get the event loop to drive the action.
>
> It kind of works but when I do this:
>
> $ /usr/local/bin/wish8.4
> % source sample.tcl
>
> I can see that the event source is created but nothing
> happens until I move the mouse over the wish window,
> likewise if I use tclsh8.4, after the event source
> is created nothing seems to happen.
>
> Is that normal or do I need to do something to boot the
> event loop?

This is because the Tcl event loop is waiting for
event, and your code doesn't seem to unblock it.
When you move the mouse cursor, Tcl event loop unblock
and then your event is queued by your Tcl_EventCheckProc.

If you need to poll your events (as it seem to be), use
Tcl_SetMaxBlockTime() in your Tcl_EventCheckProc if when you
don't queue event.

If you have another mechanism that get events in another
thread, under Windows, you can use Tcl_ThreadAlert(), even
is non-threaded Tcl.
Under Unix, this is more complicated, you need a file
descriptor for Tcl_CreateFileHandler() which help you
to unblock the event loop.

--
-eric


Report this thread to moderator Post Follow-up to this message
Old Post
Eric Boudaillier
08-25-04 10:06 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:43 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.