@@ -13,10 +13,13 @@ public class Gala.PanBackend : Object {
1313 public signal void on_update (double delta , uint64 time );
1414 public signal void on_end (double delta , uint64 time );
1515
16+ public WindowManager wm { get ; construct; }
1617 public Clutter . Actor actor { get ; construct; }
1718
1819 private GetTravelDistance get_travel_distance_func;
1920
21+ private ModalProxy ? modal_proxy;
22+
2023 private Clutter . PanAxis pan_axis;
2124 private Clutter . PanAction pan_action;
2225
@@ -34,8 +37,8 @@ public class Gala.PanBackend : Object {
3437
3538 private float travel_distance;
3639
37- public PanBackend (Clutter .Actor actor , owned GetTravelDistance get_travel_distance_func ) {
38- Object (actor: actor);
40+ public PanBackend (WindowManager wm , Clutter .Actor actor , owned GetTravelDistance get_travel_distance_func ) {
41+ Object (wm : wm, actor: actor);
3942
4043 this . get_travel_distance_func = (owned ) get_travel_distance_func;
4144 }
@@ -58,36 +61,51 @@ public class Gala.PanBackend : Object {
5861 }
5962
6063 private bool on_gesture_begin () {
64+ modal_proxy = wm. push_modal (actor);
65+ modal_proxy. allow_all_keybindings ();
66+
6167 float x_coord, y_coord;
6268 pan_action. get_press_coords (0 , out x_coord, out y_coord);
6369
6470 origin_x = current_x = x_coord;
6571 origin_y = current_y = y_coord;
6672
67- var handled = on_gesture_detected (build_gesture ());
73+ var time = pan_action. get_last_event (0 ). get_time ();
74+
75+ var handled = on_gesture_detected (build_gesture (time));
6876
6977 if (! handled) {
78+ reset ();
7079 return false ;
7180 }
7281
7382 travel_distance = get_travel_distance_func ();
7483
75- on_begin (0 , pan_action . get_last_event ( 0 ) . get_time () );
84+ on_begin (0 , time );
7685
7786 return true ;
7887 }
7988
8089 private void on_gesture_end () {
8190 on_end (calculate_percentage (), Meta . CURRENT_TIME );
8291
92+ reset ();
93+ }
94+
95+ private void reset () {
96+ if (modal_proxy != null ) {
97+ wm. pop_modal (modal_proxy);
98+ modal_proxy = null ;
99+ }
100+
83101 direction = GestureDirection . UNKNOWN ;
84102 last_n_points = 0 ;
85103 last_x_coord = 0 ;
86104 last_y_coord = 0 ;
87105 }
88106
89107 private bool on_pan (Clutter .PanAction pan_action , Clutter .Actor actor , bool interpolate ) {
90- uint64 time = pan_action. get_last_event (0 ). get_time ();
108+ var time = pan_action. get_last_event (0 ). get_time ();
91109
92110 float x, y;
93111 pan_action. get_motion_coords (0 , out x, out y);
@@ -119,7 +137,7 @@ public class Gala.PanBackend : Object {
119137 return (current - origin). abs () / travel_distance;
120138 }
121139
122- private Gesture build_gesture () {
140+ private Gesture build_gesture (uint32 timestamp ) {
123141 float delta_x, delta_y;
124142 ((Clutter . GestureAction ) pan_action). get_motion_delta (0 , out delta_x, out delta_y);
125143
@@ -137,7 +155,8 @@ public class Gala.PanBackend : Object {
137155 fingers = (int ) pan_action.get_n_current_points (),
138156 performed_on_device_type = Clutter.InputDeviceType.TOUCHSCREEN_DEVICE,
139157 origin_x = origin_x,
140- origin_y = origin_y
158+ origin_y = origin_y,
159+ timestamp = timestamp
141160 };
142161 }
143162}
0 commit comments