Skip to content

Commit 9d28d13

Browse files
committed
WindowClone: fix drag animation with multiple monitors
1 parent 4b53f12 commit 9d28d13

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Widgets/MultitaskingView/WindowClone.vala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
7272

7373
private Clutter.Actor prev_parent = null;
7474
private int prev_index = -1;
75+
private float prev_x = 0.0f;
76+
private float prev_y = 0.0f;
77+
7578
private ulong check_confirm_dialog_cb = 0;
7679
private bool in_slot_animation = false;
7780

@@ -457,12 +460,9 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
457460
var last_window_icon_x = window_icon.x;
458461
var last_window_icon_y = window_icon.y;
459462

460-
float abs_x, abs_y;
461-
float prev_parent_x, prev_parent_y;
462-
463463
prev_parent = get_parent ();
464464
prev_index = prev_parent.get_children ().index (this);
465-
prev_parent.get_transformed_position (out prev_parent_x, out prev_parent_y);
465+
prev_parent.get_transformed_position (out prev_x, out prev_y);
466466

467467
var stage = get_stage ();
468468
prev_parent.remove_child (this);
@@ -473,6 +473,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
473473
var scale = window_icon.width / clone.width;
474474
var duration = Utils.get_animation_duration (FADE_ANIMATION_DURATION);
475475

476+
float abs_x, abs_y;
476477
clone.get_transformed_position (out abs_x, out abs_y);
477478
clone.save_easing_state ();
478479
clone.set_easing_duration (duration);
@@ -486,7 +487,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
486487

487488
get_transformed_position (out abs_x, out abs_y);
488489

489-
set_position (abs_x + prev_parent_x, abs_y + prev_parent_y);
490+
set_position (abs_x, abs_y);
490491

491492
// Set the last position so that it animates from there and not 0, 0
492493
window_icon.set_position (last_window_icon_x, last_window_icon_y);
@@ -495,8 +496,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
495496
window_icon.set_easing_duration (duration);
496497
window_icon.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_CUBIC);
497498
window_icon.set_position (
498-
click_x - (abs_x + prev_parent_x) - window_icon.width / 2,
499-
click_y - (abs_y + prev_parent_y) - window_icon.height / 2
499+
click_x - abs_x - window_icon.width / 2,
500+
click_y - abs_y - window_icon.height / 2
500501
);
501502
window_icon.restore_easing_state ();
502503

@@ -643,12 +644,12 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
643644
* Animate back to our previous position with a bouncing animation.
644645
*/
645646
private void drag_canceled () {
646-
get_parent ().remove_child (this);
647-
648647
var duration = Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION);
649648

650649
// Adding to the previous parent will automatically update it to take it's slot
651650
// so to animate it we set the easing
651+
set_position (x - prev_x, y - prev_y);
652+
get_parent ().remove_child (this);
652653
save_easing_state ();
653654
set_easing_duration (duration);
654655
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);

0 commit comments

Comments
 (0)