@@ -44,6 +44,7 @@ public class Gala.GestureController : Object {
4444 public GestureAction action { get ; construct; }
4545 public WindowManager wm { get ; construct; }
4646 public Group group { get ; construct; }
47+ public bool follow_natural_scroll_settings { get ; construct; }
4748
4849 private unowned RootTarget ? _target;
4950 public RootTarget target {
@@ -87,6 +88,8 @@ public class Gala.GestureController : Object {
8788
8889 public bool recognizing { get ; private set ; }
8990
91+ private static GLib . Settings touchpad_settings = new GLib .Settings (" org.gnome.desktop.peripherals.touchpad" );
92+
9093 private ToucheggBackend ? touchegg_backend;
9194 private TouchpadBackend ? touchpad_backend;
9295 private ScrollBackend ? scroll_backend;
@@ -101,8 +104,8 @@ public class Gala.GestureController : Object {
101104
102105 private SpringTimeline ? timeline;
103106
104- public GestureController (GestureAction action, WindowManager wm, Group group = NONE ) {
105- Object (action: action, wm: wm, group: group);
107+ public GestureController (GestureAction action, WindowManager wm, Group group = NONE , bool follow_natural_scroll_settings = false ) {
108+ Object (action: action, wm: wm, group: group, follow_natural_scroll_settings : follow_natural_scroll_settings );
106109 }
107110
108111 /**
@@ -185,6 +188,8 @@ public class Gala.GestureController : Object {
185188
186189 prepare ();
187190
191+ handle_natural_scroll_settings (ref percentage);
192+
188193 gesture_progress = progress;
189194 previous_percentage = percentage;
190195 previous_time = elapsed_time;
@@ -195,6 +200,8 @@ public class Gala.GestureController : Object {
195200 return ;
196201 }
197202
203+ handle_natural_scroll_settings (ref percentage);
204+
198205 var updated_delta = previous_delta;
199206 if (elapsed_time != previous_time) {
200207 double distance = percentage - previous_percentage;
@@ -222,6 +229,7 @@ public class Gala.GestureController : Object {
222229
223230 recognizing = false ;
224231
232+ handle_natural_scroll_settings (ref percentage);
225233 update_gesture_progress (percentage, previous_delta);
226234
227235 var to = progress;
@@ -291,6 +299,25 @@ public class Gala.GestureController : Object {
291299 _action_info = null ;
292300 }
293301
302+ private void handle_natural_scroll_settings (ref double percentage) requires (recognizing_backend != null ) {
303+ if (! follow_natural_scroll_settings) {
304+ return ;
305+ }
306+
307+ var multiplier = 1.0 ;
308+
309+ switch (recognizing_backend. device_type) {
310+ case TOUCHPAD :
311+ multiplier = touchpad_settings. get_boolean (" natural-scroll" ) ? 1.0 : - 1.0 ;
312+ break ;
313+ case TOUCHSCREEN :
314+ multiplier = 1.0 ;
315+ break ;
316+ }
317+
318+ percentage * = multiplier;
319+ }
320+
294321 /**
295322 * Animates to the given progress value.
296323 * If the gesture is currently recognizing, it will do nothing.
0 commit comments