From af184927fdbdfd3d1976a1212e3088e94484bfe0 Mon Sep 17 00:00:00 2001 From: lenemter Date: Thu, 26 Oct 2023 11:54:43 +0900 Subject: [PATCH] Add "Move to workspace" gesture --- data/gala.gschema.xml | 1 + src/WindowManager.vala | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/data/gala.gschema.xml b/data/gala.gschema.xml index d502591e7..e8806975c 100644 --- a/data/gala.gschema.xml +++ b/data/gala.gschema.xml @@ -355,6 +355,7 @@ + diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 35a0101ea..c2f52e64a 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -531,17 +531,47 @@ namespace Gala { return; } - var can_handle_swipe = gesture.type == Clutter.EventType.TOUCHPAD_SWIPE && - (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT); + var can_handle_swipe = ( + gesture.type == Clutter.EventType.TOUCHPAD_SWIPE && + (gesture.direction == GestureDirection.LEFT || gesture.direction == GestureDirection.RIGHT) + ); + + if (!can_handle_swipe) { + return; + } + + var fingers = gesture.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"); + var three_finger_swipe_horizontal = GestureSettings.get_string ("three-finger-swipe-horizontal"); + var four_finger_swipe_horizontal = GestureSettings.get_string ("four-finger-swipe-horizontal"); - switch_workspace_with_gesture = can_handle_swipe && fingers; + var three_fingers_switch_to_workspace = fingers == 3 && three_finger_swipe_horizontal == "switch-to-workspace"; + var four_fingers_switch_to_workspace = fingers == 4 && four_finger_swipe_horizontal == "switch-to-workspace"; + + var three_fingers_move_to_workspace = fingers == 3 && three_finger_swipe_horizontal == "move-to-workspace"; + var four_fingers_move_to_workspace = fingers == 4 && four_finger_swipe_horizontal == "move-to-workspace"; + + switch_workspace_with_gesture = three_fingers_switch_to_workspace || four_fingers_switch_to_workspace; if (switch_workspace_with_gesture) { var direction = gesture_tracker.settings.get_natural_scroll_direction (gesture); switch_to_next_workspace (direction); + return; } + + switch_workspace_with_gesture = three_fingers_move_to_workspace || four_fingers_move_to_workspace; + if (switch_workspace_with_gesture) { + unowned var display = get_display (); + unowned var manager = display.get_workspace_manager (); + + var direction = gesture_tracker.settings.get_natural_scroll_direction (gesture); + + moving = display.focus_window; + moving.change_workspace (manager.get_active_workspace ().get_neighbor (direction)); + + switch_to_next_workspace (direction); + return; + } + } /**