@@ -160,8 +160,6 @@ public class Gala.WindowClone : Clutter.Actor {
160160 }
161161
162162 private void reallocate () {
163- var window_frame_rect = window. get_frame_rect ();
164-
165163 close_button = new Gala .CloseButton (monitor_scale_factor) {
166164 opacity = 0
167165 };
@@ -170,7 +168,6 @@ public class Gala.WindowClone : Clutter.Actor {
170168 window_icon = new WindowIcon (window, WINDOW_ICON_SIZE , (int )Math . round (monitor_scale_factor));
171169 window_icon. opacity = 0 ;
172170 window_icon. set_pivot_point (0.5f , 0.5f );
173- set_window_icon_position (window_frame_rect. width, window_frame_rect. height, monitor_scale_factor);
174171
175172 add_child (close_button);
176173 add_child (window_icon);
@@ -263,16 +260,9 @@ public class Gala.WindowClone : Clutter.Actor {
263260
264261 unowned var display = window. get_display ();
265262 var monitor_geom = display. get_monitor_geometry (window. get_monitor ());
266- var initial_scale = monitor_scale_factor;
267- var target_scale = display. get_monitor_scale (window. get_monitor ());
268- var offset_x = monitor_geom. x;
269- var offset_y = monitor_geom. y;
270-
271- var initial_width = width;
272- var initial_height = height;
273263
274- var target_x = outer_rect. x - offset_x ;
275- var target_y = outer_rect. y - offset_y ;
264+ var target_x = outer_rect. x - monitor_geom . x ;
265+ var target_y = outer_rect. y - monitor_geom . y ;
276266
277267 active = false ;
278268 update_hover_widgets (true );
@@ -284,35 +274,8 @@ public class Gala.WindowClone : Clutter.Actor {
284274 new GesturePropertyTransition (this , gesture_tracker, " shadow-opacity" , (uint8 ) 255 , (uint8 ) 0 ). start (with_gesture);
285275 new GesturePropertyTransition (window_icon, gesture_tracker, " opacity" , 255u , 0u ). start (with_gesture, () = > {
286276 update_hover_widgets (false );
287- });
288-
289- GestureTracker . OnUpdate on_animation_update = (percentage) = > {
290- var width = GestureTracker . animation_value (initial_width, outer_rect. width, percentage);
291- var height = GestureTracker . animation_value (initial_height, outer_rect. height, percentage);
292- var scale = GestureTracker . animation_value (initial_scale, target_scale, percentage);
293-
294- set_window_icon_position (width, height, scale, false );
295- };
296-
297- GestureTracker . OnEnd on_animation_end = (percentage, cancel_action) = > {
298- if (cancel_action) {
299- return ;
300- }
301-
302277 toggle_shadow (false );
303-
304- window_icon. save_easing_state ();
305- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
306- window_icon. set_easing_duration (AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION ));
307- set_window_icon_position (outer_rect. width, outer_rect. height, target_scale);
308- window_icon. restore_easing_state ();
309- };
310-
311- if (gesture_tracker == null || ! with_gesture || ! AnimationsSettings . get_enable_animations ()) {
312- on_animation_end (1 , false , 0 );
313- } else {
314- gesture_tracker. connect_handlers (null , (owned ) on_animation_update, (owned ) on_animation_end);
315- }
278+ });
316279 }
317280
318281 /**
@@ -335,10 +298,7 @@ public class Gala.WindowClone : Clutter.Actor {
335298 float intial_x = from_window_position ? outer_rect. x - monitor_geom. x : x;
336299 float intial_y = from_window_position ? outer_rect. y - monitor_geom. y : y;
337300
338- var scale = display. get_monitor_scale (display. get_monitor_index_for_rect (rect));
339-
340301 update_hover_widgets (true );
341- set_window_icon_position (initial_width, initial_height, scale);
342302
343303 new GesturePropertyTransition (this , gesture_tracker, " x" , intial_x, (float ) rect. x). start (with_gesture);
344304 new GesturePropertyTransition (this , gesture_tracker, " y" , intial_y, (float ) rect. y). start (with_gesture);
@@ -347,36 +307,8 @@ public class Gala.WindowClone : Clutter.Actor {
347307 new GesturePropertyTransition (this , gesture_tracker, " shadow-opacity" , (uint8 ) 0 , (uint8 ) 255 ). start (with_gesture);
348308 new GesturePropertyTransition (window_icon, gesture_tracker, " opacity" , 0u , 255u ). start (with_gesture, () = > {
349309 update_hover_widgets (false );
350- });
351-
352- GestureTracker . OnUpdate on_animation_update = (percentage) = > {
353- var width = GestureTracker . animation_value (initial_width, rect. width, percentage);
354- var height = GestureTracker . animation_value (initial_height, rect. height, percentage);
355-
356- set_window_icon_position (width, height, scale, false );
357- };
358-
359- GestureTracker . OnEnd on_animation_end = (percentage, cancel_action) = > {
360- if (cancel_action) {
361- return ;
362- }
363-
364- var duration = AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION );
365-
366- window_icon. save_easing_state ();
367- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
368- window_icon. set_easing_duration (duration);
369- set_window_icon_position (rect. width, rect. height, scale);
370- window_icon. restore_easing_state ();
371-
372310 toggle_shadow (true );
373- };
374-
375- if (gesture_tracker == null || ! with_gesture || ! AnimationsSettings . get_enable_animations ()) {
376- on_animation_end (1 , false , 0 );
377- } else {
378- gesture_tracker. connect_handlers (null , (owned ) on_animation_update, (owned ) on_animation_end);
379- }
311+ });
380312 }
381313
382314 public override void allocate (Clutter . ActorBox box) {
@@ -435,6 +367,15 @@ public class Gala.WindowClone : Clutter.Actor {
435367
436368 var window_title_alloc = InternalUtils . actor_box_from_rect (window_title_x, window_title_y, window_title_width, window_title_height);
437369 window_title. allocate (window_title_alloc);
370+
371+ float window_icon_width, window_icon_height;
372+ window_icon. get_preferred_size (null , null , out window_icon_width, out window_icon_height);
373+
374+ var window_icon_x = (box. get_width () - window_icon_width) / 2 ;
375+ var window_icon_y = box. get_height () - (window_icon_height * 0.75f );
376+
377+ var window_icon_alloc = InternalUtils . actor_box_from_rect (window_icon_x, window_icon_y, window_icon_width, window_icon_height);
378+ window_icon. allocate (window_icon_alloc);
438379 }
439380
440381#if HAS_MUTTER45
@@ -550,6 +491,9 @@ public class Gala.WindowClone : Clutter.Actor {
550491 * position we just freed is immediately filled by the WindowCloneContainer.
551492 */
552493 private Clutter . Actor drag_begin (float click_x, float click_y) {
494+ var last_window_icon_x = window_icon. x;
495+ var last_window_icon_y = window_icon. y;
496+
553497 float abs_x, abs_y;
554498 float prev_parent_x, prev_parent_y;
555499
@@ -581,6 +525,9 @@ public class Gala.WindowClone : Clutter.Actor {
581525
582526 set_position (abs_x + prev_parent_x, abs_y + prev_parent_y);
583527
528+ // Set the last position so that it animates from there and not 0, 0
529+ window_icon. set_position (last_window_icon_x, last_window_icon_y);
530+
584531 window_icon. save_easing_state ();
585532 window_icon. set_easing_duration (duration);
586533 window_icon. set_easing_mode (Clutter . AnimationMode . EASE_IN_OUT_CUBIC );
@@ -729,7 +676,7 @@ public class Gala.WindowClone : Clutter.Actor {
729676 */
730677 private void drag_canceled () {
731678 get_parent (). remove_child (this );
732- prev_parent. insert_child_at_index (this , prev_index);
679+ prev_parent. add_child (this ); // Add above so that it is above while it animates back to its place
733680
734681 var duration = AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION );
735682
@@ -743,28 +690,17 @@ public class Gala.WindowClone : Clutter.Actor {
743690
744691 request_reposition ();
745692
746- window_icon. save_easing_state ();
747- window_icon. set_easing_duration (duration);
748- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
749-
750- set_window_icon_position (slot. width, slot. height, monitor_scale_factor);
751- window_icon. restore_easing_state ();
752-
753693 display. set_cursor (Meta . Cursor . DEFAULT );
754- }
755-
756- private void set_window_icon_position (float window_width, float window_height, float scale_factor, bool aligned = true ) {
757- var size = InternalUtils . scale_to_int (WINDOW_ICON_SIZE , scale_factor);
758- var x = (window_width - size) / 2 ;
759- var y = window_height - (size * 0.75f );
760694
761- if (aligned) {
762- x = (int ) Math . round (x);
763- y = (int ) Math . round (y);
695+ if (duration > 0 ) {
696+ ulong handler = 0 ;
697+ handler = clone. transitions_completed. connect (() = > {
698+ prev_parent. set_child_at_index (this , prev_index); // Set the correct index so that correct stacking order is kept
699+ clone. disconnect (handler);
700+ });
701+ } else {
702+ prev_parent. set_child_at_index (this , prev_index); // Set the correct index so that correct stacking order is kept
764703 }
765-
766- window_icon. set_size (size, size);
767- window_icon. set_position (x, y);
768704 }
769705
770706 private static bool is_close_button_on_left () {
0 commit comments