diff --git a/lib/Gestures/GestureBackend.vala b/lib/Gestures/GestureBackend.vala index bf5f05feb..b7b0e1261 100644 --- a/lib/Gestures/GestureBackend.vala +++ b/lib/Gestures/GestureBackend.vala @@ -6,18 +6,11 @@ */ private interface Gala.GestureBackend : Object { - public enum DeviceType { - TOUCHPAD, - TOUCHSCREEN - } - public signal bool on_gesture_detected (Gesture gesture, uint32 timestamp); public signal void on_begin (double percentage, uint64 time); public signal void on_update (double percentage, uint64 time); public signal void on_end (double percentage, uint64 time); - public abstract DeviceType device_type { get; } - public virtual void prepare_gesture_handling () { } /** diff --git a/lib/Gestures/GestureController.vala b/lib/Gestures/GestureController.vala index b5a3497eb..42c85021d 100644 --- a/lib/Gestures/GestureController.vala +++ b/lib/Gestures/GestureController.vala @@ -44,7 +44,6 @@ public class Gala.GestureController : Object { public GestureAction action { get; construct; } public WindowManager wm { get; construct; } public Group group { get; construct; } - public bool follow_natural_scroll_settings { get; construct; } private unowned RootTarget? _target; public RootTarget target { @@ -61,6 +60,7 @@ public class Gala.GestureController : Object { public double distance { get; construct set; } public double overshoot_lower_clamp { get; construct set; default = 0d; } public double overshoot_upper_clamp { get; construct set; default = 1d; } + public bool follow_natural_scroll { get; set; default = false; } /** * When disabled gesture progress will stay where the gesture ended and not snap to full integers values. @@ -88,8 +88,6 @@ public class Gala.GestureController : Object { public bool recognizing { get; private set; } - private static GLib.Settings touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad"); - private ToucheggBackend? touchegg_backend; private TouchpadBackend? touchpad_backend; private ScrollBackend? scroll_backend; @@ -104,8 +102,8 @@ public class Gala.GestureController : Object { private SpringTimeline? timeline; - public GestureController (GestureAction action, WindowManager wm, Group group = NONE, bool follow_natural_scroll_settings = false) { - Object (action: action, wm: wm, group: group, follow_natural_scroll_settings: follow_natural_scroll_settings); + public GestureController (GestureAction action, WindowManager wm, Group group = NONE) { + Object (action: action, wm: wm, group: group); } /** @@ -169,6 +167,12 @@ public class Gala.GestureController : Object { direction_multiplier = -1; } + if (follow_natural_scroll && + !GestureSettings.is_natural_scroll_enabled (gesture.performed_on_device_type) + ) { + direction_multiplier *= -1; + } + if (snap && !Meta.Prefs.get_gnome_animations ()) { recognizing = false; prepare (); @@ -188,8 +192,6 @@ public class Gala.GestureController : Object { prepare (); - handle_natural_scroll_settings (ref percentage); - gesture_progress = progress; previous_percentage = percentage; previous_time = elapsed_time; @@ -200,8 +202,6 @@ public class Gala.GestureController : Object { return; } - handle_natural_scroll_settings (ref percentage); - var updated_delta = previous_delta; if (elapsed_time != previous_time) { double distance = percentage - previous_percentage; @@ -229,7 +229,6 @@ public class Gala.GestureController : Object { recognizing = false; - handle_natural_scroll_settings (ref percentage); update_gesture_progress (percentage, previous_delta); var to = progress; @@ -299,25 +298,6 @@ public class Gala.GestureController : Object { _action_info = null; } - private void handle_natural_scroll_settings (ref double percentage) requires (recognizing_backend != null) { - if (!follow_natural_scroll_settings) { - return; - } - - var multiplier = 1.0; - - switch (recognizing_backend.device_type) { - case TOUCHPAD: - multiplier = touchpad_settings.get_boolean ("natural-scroll") ? 1.0 : -1.0; - break; - case TOUCHSCREEN: - multiplier = 1.0; - break; - } - - percentage *= multiplier; - } - /** * Animates to the given progress value. * If the gesture is currently recognizing, it will do nothing. diff --git a/lib/Gestures/GestureSettings.vala b/lib/Gestures/GestureSettings.vala index 129524a97..92355b737 100644 --- a/lib/Gestures/GestureSettings.vala +++ b/lib/Gestures/GestureSettings.vala @@ -28,7 +28,7 @@ private class Gala.GestureSettings : Object { touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad"); } - public bool is_natural_scroll_enabled (Clutter.InputDeviceType device_type) { + public static bool is_natural_scroll_enabled (Clutter.InputDeviceType device_type) { return (device_type == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE) ? true : touchpad_settings.get_boolean ("natural-scroll"); diff --git a/lib/Gestures/ScrollBackend.vala b/lib/Gestures/ScrollBackend.vala index 883e942a7..1cf079293 100644 --- a/lib/Gestures/ScrollBackend.vala +++ b/lib/Gestures/ScrollBackend.vala @@ -26,8 +26,6 @@ private class Gala.ScrollBackend : Object, GestureBackend { private const double FINISH_DELTA_HORIZONTAL = 40; private const double FINISH_DELTA_VERTICAL = 30; - public GestureBackend.DeviceType device_type { get { return TOUCHPAD; }} - public Clutter.Orientation orientation { get; construct; } public GestureSettings settings { get; construct; } diff --git a/lib/Gestures/ToucheggBackend.vala b/lib/Gestures/ToucheggBackend.vala index bae2cfd5f..86cfefd11 100644 --- a/lib/Gestures/ToucheggBackend.vala +++ b/lib/Gestures/ToucheggBackend.vala @@ -76,8 +76,6 @@ private class Gala.ToucheggBackend : Object, GestureBackend { */ private const double DELTA_MULTIPLIER = 0.01; - public GestureBackend.DeviceType device_type { get { return TOUCHPAD; }} - /** * Single instance of the class. */ diff --git a/lib/Gestures/TouchpadBackend.vala b/lib/Gestures/TouchpadBackend.vala index c76c8f8e7..f7883c5c5 100644 --- a/lib/Gestures/TouchpadBackend.vala +++ b/lib/Gestures/TouchpadBackend.vala @@ -18,8 +18,6 @@ private class Gala.TouchpadBackend : Object, GestureBackend { ONGOING } - public GestureBackend.DeviceType device_type { get { return TOUCHPAD; }} - public Clutter.Actor actor { get; construct; } public GestureController.Group group { get; construct; } diff --git a/src/Widgets/MultitaskingView/MultitaskingView.vala b/src/Widgets/MultitaskingView/MultitaskingView.vala index 49c803937..fefb94ea3 100644 --- a/src/Widgets/MultitaskingView/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView/MultitaskingView.vala @@ -65,8 +65,9 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone workspaces = new WorkspaceRow (display); - workspaces_gesture_controller = new GestureController (SWITCH_WORKSPACE, wm, MULTITASKING_VIEW, true) { - overshoot_upper_clamp = 0.1 + workspaces_gesture_controller = new GestureController (SWITCH_WORKSPACE, wm, MULTITASKING_VIEW) { + overshoot_upper_clamp = 0.1, + follow_natural_scroll = true, }; workspaces_gesture_controller.enable_touchpad (wm.stage); workspaces_gesture_controller.enable_scroll (this, HORIZONTAL);