Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/Gestures/GestureBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () { }

/**
Expand Down
38 changes: 9 additions & 29 deletions lib/Gestures/GestureController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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 ();
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/Gestures/GestureSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions lib/Gestures/ScrollBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
2 changes: 0 additions & 2 deletions lib/Gestures/ToucheggBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 0 additions & 2 deletions lib/Gestures/TouchpadBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
5 changes: 3 additions & 2 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down