Skip to content
Open
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
14 changes: 13 additions & 1 deletion lib/Gestures/GestureController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public class Gala.GestureController : Object {
*/
public void goto (double to) {
var clamped_to = to.clamp ((int) overshoot_lower_clamp, (int) overshoot_upper_clamp);
if (progress == to || recognizing ||
if (recognizing || timeline == null && progress == to ||
timeline != null && clamped_to == timeline.value_to // Only allow overshoot if there's no ongoing overshoot animation to prevent stacking
) {
return;
Expand All @@ -301,6 +301,18 @@ public class Gala.GestureController : Object {
finish ((to > progress ? 1 : -1) * 1, to);
}

public void jump (double to) {
if (running && !recognizing) {
/* We are animating to a snap point so stop the animation */
finished ();
}

var clamped_to = to.clamp ((int) overshoot_lower_clamp, (int) overshoot_upper_clamp);

target?.propagate (COMMIT, action, clamped_to);
progress = clamped_to;
}

public void cancel_gesture () {
if (recognizing) {
recognizing_backend.cancel_gesture ();
Expand Down
16 changes: 11 additions & 5 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
unowned var manager = display.get_workspace_manager ();
manager.workspace_added.connect (add_workspace);
manager.workspace_removed.connect (remove_workspace);
manager.workspaces_reordered.connect (on_workspaces_reordered);
manager.workspaces_reordered.connect (sync_active_workspace);
manager.workspace_switched.connect (on_workspace_switched);

workspaces_gesture_controller.overshoot_lower_clamp = -manager.n_workspaces - 0.1 + 1;
Expand Down Expand Up @@ -329,6 +329,8 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
workspaces.insert_child_at_index (workspace, num);

workspace.window_selected.connect (window_selected);

sync_active_workspace ();
}

private void remove_workspace (int num) {
Expand Down Expand Up @@ -356,12 +358,16 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
workspace.window_selected.disconnect (window_selected);
workspace.destroy ();

workspaces_gesture_controller.progress = -manager.get_active_workspace_index ();
sync_active_workspace ();
}

private void on_workspaces_reordered () {
unowned var manager = display.get_workspace_manager ();
workspaces_gesture_controller.progress = -manager.get_active_workspace_index ();
private void sync_active_workspace () {
if (workspaces_gesture_controller.recognizing) {
return;
}

var target = -display.get_workspace_manager ().get_active_workspace_index ();
workspaces_gesture_controller.jump (target);
}

private void on_workspace_switched (int from, int to) {
Expand Down