diff --git a/data/gala.gschema.xml b/data/gala.gschema.xml index 5806e76f..872a9795 100644 --- a/data/gala.gschema.xml +++ b/data/gala.gschema.xml @@ -1,7 +1,7 @@ - + @@ -26,7 +26,7 @@ - 'none' + "none" Action for the top left corner @@ -36,17 +36,17 @@ Choose the algorithm used for exposing the windows. - 'none' + "none" Action for the top right corner - 'none' + "none" Action for the bottom left corner - 'none' + "none" Action for the bottom right corner @@ -314,39 +314,50 @@ + + + + + + + + + + + + + + - - true - Multitasking view gesture - If enabled, swipe up with the number of fingers set in io.elementary.desktop.wm.gestures.multitasking-gesture-fingers to show the multitasking view + + "none" + Three-finger pinch gesture + The action that corresponds to performing a pinch gesture with three fingers - - 3 - - Multitasking view gesture fingers - Number of fingers used in the multitasking view gesture + + "none" + Four-finger pinch gesture + The action that corresponds to performing a pinch gesture with four fingers - - true - Switch workspace gesture - If enabled, swipe left/right with the number of fingers set in io.elementary.desktop.wm.gestures.workspaces-gesture-fingers to switch between workspaces + + "multitasking-view" + Three-finger up-swipe gesture + The action that corresponds to swiping up with three fingers - - 3 - - Switch workspace gesture fingers - Number of fingers used in the switch workspaces gesture + + "none" + Four-finger up-swipe gesture + The action that corresponds to swiping up with four fingers - - false - Zoom gesture - If enabled, pinch with the number of fingers set in io.elementary.desktop.wm.gestures.multitasking-gesture-fingers to zoom in/out the entire desktop + + "switch-to-workspace" + Three-finger horizontal swipe gesture + The action that corresponds to performing a horizontal swipe gesture with three fingers - - 3 - - Zoom gesture fingers - Number of fingers used in the zoom gesture + + "none" + Four-finger horizontal swipe gesture + The action that corresponds to performing a horizontal swipe gesture with four fingers diff --git a/src/Gestures/GestureSettings.vala b/src/Gestures/GestureSettings.vala index 0944df1a..c7a913f9 100644 --- a/src/Gestures/GestureSettings.vala +++ b/src/Gestures/GestureSettings.vala @@ -23,15 +23,6 @@ public class Gala.GestureSettings : Object { private static GLib.Settings gala_settings; private static GLib.Settings touchpad_settings; - public const string MULTITASKING_ENABLED = "multitasking-gesture-enabled"; - public const string MULTITASKING_FINGERS = "multitasking-gesture-fingers"; - - public const string WORKSPACE_ENABLED = "workspaces-gesture-enabled"; - public const string WORKSPACE_FINGERS = "workspaces-gesture-fingers"; - - public const string ZOOM_ENABLED = "zoom-gesture-enabled"; - public const string ZOOM_FINGERS = "zoom-gesture-fingers"; - static construct { gala_settings = new GLib.Settings ("io.elementary.desktop.wm.gestures"); touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad"); @@ -75,11 +66,7 @@ public class Gala.GestureSettings : Object { } } - public bool is_gesture_enabled (string setting_id) { - return gala_settings.get_boolean (setting_id); - } - - public int gesture_fingers (string setting_id) { - return gala_settings.get_int (setting_id); + public static string get_string (string setting_id) { + return gala_settings.get_string (setting_id); } } diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 08fa8bab..d9cc4402 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -207,22 +207,17 @@ namespace Gala { } private void on_multitasking_gesture_detected (Gesture gesture) { - var enabled = workspace_gesture_tracker.settings.is_gesture_enabled (GestureSettings.MULTITASKING_ENABLED); - var fingers = workspace_gesture_tracker.settings.gesture_fingers (GestureSettings.MULTITASKING_FINGERS); + if (gesture.type != Gdk.EventType.TOUCHPAD_SWIPE || + (gesture.fingers == 3 && GestureSettings.get_string ("three-finger-swipe-up") != "multitasking-view") || + (gesture.fingers == 4 && GestureSettings.get_string ("four-finger-swipe-up") != "multitasking-view") + ) { + return; + } - bool up = gesture.direction == GestureDirection.UP; - bool down = gesture.direction == GestureDirection.DOWN; - bool can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE - && (up || down) - && gesture.fingers == fingers; - bool can_handle_gesture = enabled && can_handle_swipe; - - if (can_handle_gesture) { - if (up && !opened) { - toggle (true, false); - } else if (down && opened) { - toggle (true, false); - } + if (gesture.direction == GestureDirection.UP && !opened) { + toggle (true, false); + } else if (gesture.direction == GestureDirection.DOWN && opened) { + toggle (true, false); } } @@ -231,16 +226,13 @@ namespace Gala { return; } - var enabled = workspace_gesture_tracker.settings.is_gesture_enabled (GestureSettings.WORKSPACE_ENABLED); - var fingers = workspace_gesture_tracker.settings.gesture_fingers (GestureSettings.WORKSPACE_FINGERS); + var can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE && + (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT); - bool can_handle_scroll = gesture.type == Gdk.EventType.SCROLL; - bool can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE - && (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT) - && gesture.fingers == fingers; - bool can_handle_gesture = enabled && (can_handle_scroll || can_handle_swipe); + var fingers = (gesture.fingers == 3 && Gala.GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || + (gesture.fingers == 4 && Gala.GestureSettings.get_string ("four-finger-swipe-horizontal") == "switch-to-workspace"); - if (can_handle_gesture) { + if (gesture.type == Gdk.EventType.SCROLL || (can_handle_swipe && fingers)) { var direction = workspace_gesture_tracker.settings.get_natural_scroll_direction (gesture); switch_workspace_with_gesture (direction); } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 00eb4b80..dc83221c 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -481,14 +481,13 @@ namespace Gala { return; } - var enabled = gesture_tracker.settings.is_gesture_enabled (GestureSettings.WORKSPACE_ENABLED); - var fingers = gesture_tracker.settings.gesture_fingers (GestureSettings.WORKSPACE_FINGERS); + var can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE && + (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT); - bool can_handle_gesture = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE - && (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT) - && gesture.fingers == fingers; + var fingers = (gesture.fingers == 3 && GestureSettings.get_string ("three-finger-swipe-horizontal") == "switch-to-workspace") || + (gesture.fingers == 4 && GestureSettings.get_string ("four-finger-swipe-horizontal") == "switch-to-workspace"); - switch_workspace_with_gesture = enabled && can_handle_gesture; + switch_workspace_with_gesture = can_handle_swipe && fingers; if (switch_workspace_with_gesture) { var direction = gesture_tracker.settings.get_natural_scroll_direction (gesture); switch_to_next_workspace (direction); diff --git a/src/Zoom.vala b/src/Zoom.vala index 40eadfe5..9edfd42a 100644 --- a/src/Zoom.vala +++ b/src/Zoom.vala @@ -71,14 +71,15 @@ namespace Gala { } private void on_gesture_detected (Gesture gesture) { - var enabled = gesture_tracker.settings.is_gesture_enabled (GestureSettings.ZOOM_ENABLED); - var fingers = gesture_tracker.settings.gesture_fingers (GestureSettings.ZOOM_FINGERS); + if (gesture.type != Gdk.EventType.TOUCHPAD_PINCH || + (gesture.direction != GestureDirection.IN && gesture.direction != GestureDirection.OUT) + ) { + return; + } - bool can_handle_gesture = gesture.type == Gdk.EventType.TOUCHPAD_PINCH - && (gesture.direction == GestureDirection.IN || gesture.direction == GestureDirection.OUT) - && gesture.fingers == fingers; - - if (enabled && can_handle_gesture) { + if ((gesture.fingers == 3 && GestureSettings.get_string ("three-finger-pinch") == "zoom") || + (gesture.fingers == 4 && GestureSettings.get_string ("four-finger-pinch") == "zoom") + ) { zoom_with_gesture (gesture.direction); } }