Skip to content

Commit

Permalink
Add "Move to workspace" gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter committed Oct 26, 2023
1 parent 91d70aa commit af18492
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
<enum id="GestureSwipeHorizontal">
<value nick="none" value="0" />
<value nick="switch-to-workspace" value="1" />
<value nick="move-to-workspace" value="2" />
</enum>
<enum id="GestureSwipeUp">
<value nick="none" value="0" />
Expand Down
40 changes: 35 additions & 5 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

/**
Expand Down

0 comments on commit af18492

Please sign in to comment.