Hi,
as I previously wrote, the current method of processing the TS samples
are not working well ( with eglnative backend).
If clutter_event_dispatch lasts too long, TS samples are dropped witch
make CLUTTER_MOTION not
followed by a CLUTTER_BUTTON_RELEASE.
I propose this patch to fix this.
Note : this is a resend, I guess my previous mail didn't reach this
list, because I didn't read any feedback.
Regards
Olivier Butler
OZE - Chief Product Manager
--- clutter-event-egl-org.c 2008-07-10 16:27:09.000000000 +0200
+++ clutter-event-egl.c 2008-07-16 12:02:49.000000000 +0200
@@ -107,7 +107,7 @@
source = backend_egl->event_source = clutter_event_source_new (backend);
event_source = (ClutterEventSource *) source;
- event_source->ts_device = ts_open (g_getenv ("TSLIB_TSDEVICE"), 0);
+ event_source->ts_device = ts_open (g_getenv ("TSLIB_TSDEVICE"), 1);
if (event_source->ts_device)
{
@@ -209,7 +209,7 @@
ClutterEventSource *event_source = (ClutterEventSource *) source;
ClutterEvent *event;
#ifdef HAVE_TSLIB
- struct ts_sample tsevent;
+ struct ts_sample tsevent,tsevent_read,tsevent_first,tsevent_last;
#endif
ClutterMainContext *clutter_context;
static gint last_x = 0, last_y = 0;
@@ -221,9 +221,32 @@
#ifdef HAVE_TSLIB
/* FIXME while would be better here but need to deal with lockups */
- if ((!clutter_events_pending()) &&
- (ts_read(event_source->ts_device, &tsevent, 1) == 1))
+ if ( !clutter_events_pending() )
{
+ int nbts ;
+ int tslast = 0 ;
+ int tsfirst = 0 ;
+ /* FIXME empty the ts buffer, in case of clutter_event_dispatch is
slower than ts events
+ take the fist sample on ts pressing, take the last sample on motion
and ts release */
+ do
+ {
+ nbts = ts_read(event_source->ts_device, &tsevent_read, 1);
+ if ( (nbts == 1 ) && ( tsfirst == 0 ) ) { tsevent_first =
tsevent_read ; tsfirst = 1 ; }
+ if (nbts == 1 ) { tsevent_last = tsevent_read ; tslast = 1 ; }
+ } while ( nbts ) ;
+
+ if ( (!tsfirst) && (!tslast) )
+ goto out ;
+
+ if ( clicked == FALSE )
+ {
+ tsevent = tsevent_first ;
+ }
+ else
+ {
+ tsevent = tsevent_last ;
+ }
+
/* Avoid sending too many events which are just pressure changes.
* We dont current handle pressure in events (FIXME) and thus
* event_button_generate gets confused generating lots of double