Skip to content

Commit a38a883

Browse files
authored
WindowClone: fix drag animation with multiple monitors (#2501)
1 parent 0035139 commit a38a883

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

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

461-
float abs_x, abs_y;
462-
float prev_parent_x, prev_parent_y;
463-
464464
prev_parent = get_parent ();
465465
prev_index = prev_parent.get_children ().index (this);
466-
prev_parent.get_transformed_position (out prev_parent_x, out prev_parent_y);
466+
prev_parent.get_transformed_position (out prev_x, out prev_y);
467467

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

477+
float abs_x, abs_y;
477478
clone.get_transformed_position (out abs_x, out abs_y);
478479
clone.save_easing_state ();
479480
clone.set_easing_duration (duration);
@@ -487,7 +488,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
487488

488489
get_transformed_position (out abs_x, out abs_y);
489490

490-
set_position (abs_x + prev_parent_x, abs_y + prev_parent_y);
491+
set_position (abs_x, abs_y);
491492

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

@@ -584,12 +585,12 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
584585
* Animate back to our previous position with a bouncing animation.
585586
*/
586587
private void drag_canceled () {
587-
get_parent ().remove_child (this);
588-
589588
var duration = Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION);
590589

591590
// Adding to the previous parent will automatically update it to take it's slot
592591
// so to animate it we set the easing
592+
set_position (x - prev_x, y - prev_y);
593+
get_parent ().remove_child (this);
593594
save_easing_state ();
594595
set_easing_duration (duration);
595596
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);

0 commit comments

Comments
 (0)