Skip to content

Commit 31277d1

Browse files
authored
Merge branch 'main' into leolost/gesture-controller-test-finalize
2 parents bd3eb37 + c4891b3 commit 31277d1

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

lib/Gestures/GestureController.vala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ public class Gala.GestureController : Object {
287287

288288
private void finished () {
289289
assert (running);
290-
target.propagate (END, action, progress);
291290
running = false;
292291
remove_timeline ();
292+
target.propagate (END, action, progress);
293293
}
294294

295295
private void remove_timeline () {
@@ -319,6 +319,18 @@ public class Gala.GestureController : Object {
319319
finish ((to > progress ? 1 : -1) * 1, to);
320320
}
321321

322+
public void jump (double to) {
323+
if (running && !recognizing) {
324+
/* We are animating to a snap point so stop the animation */
325+
finished ();
326+
}
327+
328+
var clamped_to = to.clamp ((int) overshoot_lower_clamp, (int) overshoot_upper_clamp);
329+
330+
target?.propagate (COMMIT, action, clamped_to);
331+
progress = clamped_to;
332+
}
333+
322334
public void cancel_gesture () {
323335
if (recognizing) {
324336
recognizing_backend.cancel_gesture ();

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public class Gala.MultitaskingView : Root, RootTarget, ActivatableComponent {
9292
add_child (StaticWindowContainer.get_instance (display));
9393

9494
unowned var manager = display.get_workspace_manager ();
95+
manager.workspace_added.connect (sync_active_workspace);
9596
manager.workspace_removed.connect (sync_active_workspace);
9697
manager.workspaces_reordered.connect (sync_active_workspace);
9798
manager.workspace_switched.connect (on_workspace_switched);
@@ -302,8 +303,12 @@ public class Gala.MultitaskingView : Root, RootTarget, ActivatableComponent {
302303
}
303304

304305
private void sync_active_workspace () {
305-
unowned var manager = display.get_workspace_manager ();
306-
workspaces_gesture_controller.progress = -manager.get_active_workspace_index ();
306+
if (workspaces_gesture_controller.recognizing) {
307+
return;
308+
}
309+
310+
var target = -display.get_workspace_manager ().get_active_workspace_index ();
311+
workspaces_gesture_controller.jump (target);
307312
}
308313

309314
private void on_workspace_switched (int from, int to) {

0 commit comments

Comments
 (0)