nanogui: Difficulty Using GrInjectKeyboardEvent()


Previous by date: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr
Next by date: 29 Aug 2008 06:25:08 -0000 TinyWidget's events, RAHUL RAVINDRAN
Previous in thread: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr
Next in thread: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr

Subject: Re: [nanogui] Difficulty Using GrInjectKeyboardEvent()
From: Kees Schoenmakers ####@####.####
Date: 29 Aug 2008 06:25:08 -0000
Message-Id: <200808290823.51953.k.schoenmakers@sigmae.nl>

On donderdag 28 augustus 2008, Greg Haerr wrote:
> > 3.  send it on to clients that are selecting on the event.
> > Using GrInjectKeyboardEvent() only does the first two things.
>
> Of course...  the client thread is hanging on a real select() call
> in srvmain.c::GsSelect(), and doesn't unblock just because
> the other thread posted an event into a memory location.
>
> We'll need some IPC method of having the calling thread
> unblock the waiting thread when the event is posted.
>
> The reason I think this works in the non LINK_APP_INTO_SERVER
> case is because the server checks for events in application
> queues and sends a byte across the pipe for any applications
> which are currently blocked in GrGetNextEvent, which
> wakes them up by allowing them to read.
>
> In your case, one simple approach would be to never
> hang in GrGetNextEvent very long, that is, set a small
> interval timeout, which will cause the thread to at
> least loop once in GsSelect every so many milliseconds.
>
> Regards,
>
> Greg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####

Hi,

I use nano-X together with TinyWidgets for a process (variables) display. Here 
the information is updated by the application, not by user input (most of the 
time). TinyWidgets normally would 'hang' in 

void
tnMainLoop (void)
{
GrMainLoop(EventResolveRoutine);
}

so my process variables are not handled.

I modfied tnMainLoop to

void
tnMainLoop (int flag)
{
 fd_set  rfds;
  int     setsize = 0;
   struct timeval wtime;

 wtime.tv_sec = 0;
 if(flag)
	 wtime.tv_usec = 1000;
 else
 	wtime.tv_usec = 0;

   FD_ZERO(&rfds);
     GrPrepareSelect(&setsize, &rfds);
     if(select(setsize+1, &rfds, NULL, NULL, &wtime) > 0)
         GrServiceSelect(&rfds, EventResolveRoutine);
}

This makes the application active contineously while checking for events to 
handle when it has time to.

regards

Kees


Previous by date: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr
Next by date: 29 Aug 2008 06:25:08 -0000 TinyWidget's events, RAHUL RAVINDRAN
Previous in thread: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr
Next in thread: 29 Aug 2008 06:25:08 -0000 Re: Difficulty Using GrInjectKeyboardEvent(), Greg Haerr


Powered by ezmlm-browse 0.20.