@@ -25,6 +25,13 @@ public class Gala.PanBackend : Object {
2525 private float origin_x;
2626 private float origin_y;
2727
28+ private float current_x;
29+ private float current_y;
30+
31+ private float last_x_coord;
32+ private float last_y_coord;
33+ private uint last_n_points;
34+
2835 private float travel_distance;
2936
3037 public PanBackend (Clutter .Actor actor , owned GetTravelDistance get_travel_distance_func ) {
@@ -54,8 +61,8 @@ public class Gala.PanBackend : Object {
5461 float x_coord, y_coord;
5562 pan_action. get_press_coords (0 , out x_coord, out y_coord);
5663
57- origin_x = x_coord;
58- origin_y = y_coord;
64+ origin_x = current_x = x_coord;
65+ origin_y = current_y = y_coord;
5966
6067 var handled = on_gesture_detected (build_gesture ());
6168
@@ -71,25 +78,38 @@ public class Gala.PanBackend : Object {
7178 }
7279
7380 private void on_gesture_end () {
74- float x_coord, y_coord ;
75- pan_action . get_motion_coords ( 0 , out x_coord, out y_coord);
76- on_end (calculate_percentage (x_coord, y_coord ), pan_action. get_last_event (0 ). get_time ());
81+ update_coords () ;
82+
83+ on_end (calculate_percentage (), pan_action. get_last_event (0 ). get_time ());
7784
7885 direction = GestureDirection . UNKNOWN ;
7986 }
8087
8188 private bool on_pan (Clutter .PanAction pan_action , Clutter .Actor actor , bool interpolate ) {
8289 uint64 time = pan_action. get_last_event (0 ). get_time ();
8390
84- float x_coord, y_coord;
85- pan_action. get_motion_coords (0 , out x_coord, out y_coord);
91+ update_coords ();
8692
87- on_update (calculate_percentage (x_coord, y_coord ), time);
93+ on_update (calculate_percentage (), time);
8894
8995 return true ;
9096 }
9197
92- private double calculate_percentage (float current_x , float current_y ) {
98+ private void update_coords () {
99+ float x, y;
100+ pan_action. get_motion_coords (0 , out x, out y);
101+
102+ if (pan_action. get_n_current_points () == last_n_points) {
103+ current_x + = x - last_x_coord;
104+ current_y + = y - last_y_coord;
105+ }
106+
107+ last_x_coord = x;
108+ last_y_coord = y;
109+ last_n_points = pan_action. get_n_current_points ();
110+ }
111+
112+ private double calculate_percentage () {
93113 float current, origin;
94114 if (pan_axis == X_AXIS ) {
95115 current = direction == RIGHT ? float . max (current_x, origin_x) : float . min (current_x, origin_x);
0 commit comments