Hi Emmanuele,

here is a rewrite of the patch, I hope it will be ok for you.


Regards
Olivier

--- 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


Le 15 juil. 08 à 18:40, Emmanuele Bassi a écrit :

On Tue, 2008-07-15 at 18:30 +0200, Olivier Butler wrote:

 I attached to this mail a possible fix, witch empty the ts stream at
the beginning of each the clutter_event_dispatch.

Any comments are welcome.

I'll leave others to comment on the actual fix - I'll just comment on
the code style.

the patch manages not only to *not* follow any of the code style of the
surrounding lines, but it also breaks the code style on non-related
lines for no apparent reason.

-  event_source->ts_device = ts_open (g_getenv ("TSLIB_TSDEVICE"), 0);
+ event_source->ts_device = ts_open (g_getenv ("TSLIB_TSDEVICE"), 1 /*0*/);

just remove the comment.

-      g_source_set_can_recurse (source, TRUE);
+      g_source_set_can_recurse (source, TRUE );

don't add useless whitespace.

+
+
#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;
  static gboolean     clicked = FALSE;
-
+

again, whitespace.

+
+
#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()) ) /*&&
+        (ts_read(event_source->ts_device, &tsevent, 1) == 1) */)
    {
+

again, whitespace. and could you care to elaborate the FIXME here?

+/* empty the ts buffer, in case of clutter_dispatch is slower than ts events
+take the fist sample on ts pressing
+take the last sample on motion and ts release  */
+
+int nbts ;
+int tslast = 0 ;
+int tsfirst = 0 ;
+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 ;
+
+

this lacks whitespace, indentation, newlines and uses C99 declarations.

- if (tsevent.pressure && last_x == tsevent.x && last_y == tsevent.y)
-        goto out;
+
+ if (tsevent.pressure && last_x == tsevent.x && last_y == tsevent.y)
+       goto out;

useless whitespace change.

@@ -245,7 +271,6 @@
          event->button.time = get_backend_time ();
          event->button.modifier_state = 0;
          event->button.button = 1;
-
          clicked = TRUE;
        }
      else if (tsevent.pressure && clicked)
@@ -253,19 +278,20 @@
          event->motion.type = event->type = CLUTTER_MOTION;
          event->motion.time = get_backend_time ();
          event->motion.modifier_state = 0;
-        }
+
+       }
      else
        {
         event->button.type = event->type = CLUTTER_BUTTON_RELEASE;
          event->button.time = get_backend_time ();
          event->button.modifier_state = 0;
          event->button.button = 1;
-
          clicked = FALSE;
        }

-      g_queue_push_head (clutter_context->events_queue, event);
-    }
+     g_queue_push_head (clutter_context->events_queue, event);
+
+}

useless whitespace change.

could you please rewrite your patch so that it conforms with the rest of
the codebase you're modifying? it makes it really hard to even comment
on the correctness of the code.

ciao,
Emmanuele.

--
Emmanuele Bassi, OpenedHand Ltd.
Unit R, Homesdale Business Centre
216-218 Homesdale Rd., Bromley - BR12QZ
http://www.o-hand.com

--
To unsubscribe send a mail to [EMAIL PROTECTED]


Reply via email to