+ Evas_Coord ox = 0, oy = 0, fx = 0, fy= 0;
+
+ fx = sd->down.hold_x;
+ fy = sd->down.hold_y;
+
+ if ((!sd->hold) && (!sd->freeze) && (_elm_config->scroll_smooth_time_interval > 0.0))
+ {
+ int i, count = 0; //count for the real event number we have to deal with
+ int queue_size = 10; //for event queue size
+ int src_index = 0, dst_index = 0;
+ int xsum = 0, ysum=0;
+ Evas_Coord x=0, y=0;
+
+ struct {
+ Evas_Coord x, y;
+ double t;
+ } pos[queue_size];
+
+ double tdiff, tnow;
+ double time_interval=_elm_config->scroll_smooth_time_interval;
+ // FIXME: assume server and client have the same "timezone"
+ // (0 timepoint) for now. this needs to be figured out in advance
+ // though.
+ tdiff = sd->down.hist.est_timestamp_diff;
+ tnow = ecore_time_get() - tdiff;
+
+ for(i = 0; i < queue_size; i++)
+ {
+ x = sd->down.history[i].x;
+ y = sd->down.history[i].y;
+
+ //if there is no history value , we don't deal with it
+ //if there is better wat to know existance of history value , I will modify this code to it
+ if ( (x == 0) && (y == 0) )
+ {
+ break;
+ }
+ _down_coord_eval(sd, &x, &y);
+
+ pos[i].x = x;
+ pos[i].y = y;
+ pos[i].t = tnow - sd->down.history[i].timestamp;
+ }
+ count = --i;
+
+ // we only deal with smooth scroll there is enough history
+ for(i = 0; i < queue_size; i++)
+ {
+ if (src_index > count) break;
+ if (i == 0)
+ {
+ xsum = pos[i].x;
+ ysum = pos[i].y;
+ dst_index++;
+ continue;
+ }
+ while ((pos[src_index].t < time_interval *i) &&
+ (src_index <= count))
+ {
+ src_index++;
+ }
+ if (src_index <= count)
+ {
+ xsum += pos[src_index].x;
+ ysum += pos[src_index].y;
+ dst_index++;
+ }
+ }
+ fx = xsum / dst_index;
+ fy = ysum / dst_index;
+ }