@@ -159,8 +159,6 @@ public class Gala.WindowClone : Clutter.Actor {
159159 }
160160
161161 private void reallocate () {
162- var window_frame_rect = window. get_frame_rect ();
163-
164162 close_button = new Gala .CloseButton (monitor_scale_factor) {
165163 opacity = 0
166164 };
@@ -169,7 +167,6 @@ public class Gala.WindowClone : Clutter.Actor {
169167 window_icon = new WindowIcon (window, WINDOW_ICON_SIZE , (int )Math . round (monitor_scale_factor));
170168 window_icon. opacity = 0 ;
171169 window_icon. set_pivot_point (0.5f , 0.5f );
172- set_window_icon_position (window_frame_rect. width, window_frame_rect. height, monitor_scale_factor);
173170
174171 add_child (close_button);
175172 add_child (window_icon);
@@ -276,16 +273,8 @@ public class Gala.WindowClone : Clutter.Actor {
276273
277274 unowned var display = window. get_display ();
278275 var monitor_geom = display. get_monitor_geometry (window. get_monitor ());
279- var initial_scale = monitor_scale_factor;
280- var target_scale = display. get_monitor_scale (window. get_monitor ());
281- var offset_x = monitor_geom. x;
282- var offset_y = monitor_geom. y;
283-
284- var initial_width = width;
285- var initial_height = height;
286-
287- var target_x = outer_rect. x - offset_x;
288- var target_y = outer_rect. y - offset_y;
276+ var target_x = outer_rect. x - monitor_geom. x;
277+ var target_y = outer_rect. y - monitor_geom. y;
289278
290279 active = false ;
291280 update_hover_widgets (true );
@@ -297,35 +286,8 @@ public class Gala.WindowClone : Clutter.Actor {
297286 new GesturePropertyTransition (this , gesture_tracker, " shadow-opacity" , (uint8 ) 255 , (uint8 ) 0 ). start (with_gesture);
298287 new GesturePropertyTransition (window_icon, gesture_tracker, " opacity" , 255u , 0u ). start (with_gesture, () = > {
299288 update_hover_widgets (false );
300- });
301-
302- GestureTracker . OnUpdate on_animation_update = (percentage) = > {
303- var width = GestureTracker . animation_value (initial_width, outer_rect. width, percentage);
304- var height = GestureTracker . animation_value (initial_height, outer_rect. height, percentage);
305- var scale = GestureTracker . animation_value (initial_scale, target_scale, percentage);
306-
307- set_window_icon_position (width, height, scale, false );
308- };
309-
310- GestureTracker . OnEnd on_animation_end = (percentage, cancel_action) = > {
311- if (cancel_action) {
312- return ;
313- }
314-
315289 toggle_shadow (false );
316-
317- window_icon. save_easing_state ();
318- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
319- window_icon. set_easing_duration (AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION ));
320- set_window_icon_position (outer_rect. width, outer_rect. height, target_scale);
321- window_icon. restore_easing_state ();
322- };
323-
324- if (gesture_tracker == null || ! with_gesture || ! AnimationsSettings . get_enable_animations ()) {
325- on_animation_end (1 , false , 0 );
326- } else {
327- gesture_tracker. connect_handlers (null , (owned ) on_animation_update, (owned ) on_animation_end);
328- }
290+ });
329291 }
330292
331293 /**
@@ -348,10 +310,7 @@ public class Gala.WindowClone : Clutter.Actor {
348310 float intial_x = from_window_position ? outer_rect. x - monitor_geom. x : x;
349311 float intial_y = from_window_position ? outer_rect. y - monitor_geom. y : y;
350312
351- var scale = display. get_monitor_scale (display. get_monitor_index_for_rect (rect));
352-
353313 update_hover_widgets (true );
354- set_window_icon_position (initial_width, initial_height, scale);
355314
356315 new GesturePropertyTransition (this , gesture_tracker, " x" , intial_x, (float ) rect. x). start (with_gesture);
357316 new GesturePropertyTransition (this , gesture_tracker, " y" , intial_y, (float ) rect. y). start (with_gesture);
@@ -360,42 +319,14 @@ public class Gala.WindowClone : Clutter.Actor {
360319 new GesturePropertyTransition (this , gesture_tracker, " shadow-opacity" , (uint8 ) 0 , (uint8 ) 255 ). start (with_gesture);
361320 new GesturePropertyTransition (window_icon, gesture_tracker, " opacity" , 0u , 255u ). start (with_gesture, () = > {
362321 update_hover_widgets (false );
363- });
364-
365- GestureTracker . OnUpdate on_animation_update = (percentage) = > {
366- var width = GestureTracker . animation_value (initial_width, rect. width, percentage);
367- var height = GestureTracker . animation_value (initial_height, rect. height, percentage);
368-
369- set_window_icon_position (width, height, scale, false );
370- };
371-
372- GestureTracker . OnEnd on_animation_end = (percentage, cancel_action) = > {
373- if (cancel_action) {
374- return ;
375- }
376-
377- var duration = AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION );
378-
379- window_icon. save_easing_state ();
380- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
381- window_icon. set_easing_duration (duration);
382- set_window_icon_position (rect. width, rect. height, scale);
383- window_icon. restore_easing_state ();
384-
385322 toggle_shadow (true );
386- };
387-
388- if (gesture_tracker == null || ! with_gesture || ! AnimationsSettings . get_enable_animations ()) {
389- on_animation_end (1 , false , 0 );
390- } else {
391- gesture_tracker. connect_handlers (null , (owned ) on_animation_update, (owned ) on_animation_end);
392- }
323+ });
393324 }
394325
395326 public override void allocate (Clutter . ActorBox box) {
396327 base . allocate (box);
397328
398- if (clone == null || (drag_action != null && drag_action . dragging) ) {
329+ if (clone == null ) {
399330 return ;
400331 }
401332
@@ -448,6 +379,13 @@ public class Gala.WindowClone : Clutter.Actor {
448379
449380 var window_title_alloc = InternalUtils . actor_box_from_rect (window_title_x, window_title_y, window_title_width, window_title_height);
450381 window_title. allocate (window_title_alloc);
382+
383+ var window_icon_size = InternalUtils . scale_to_int (WINDOW_ICON_SIZE , monitor_scale);
384+ var window_icon_x = (box. get_width () - window_icon_size) / 2 ;
385+ var window_icon_y = box. get_height () - (window_icon_size * 0.75f );
386+
387+ var window_icon_alloc = InternalUtils . actor_box_from_rect (window_icon_x, window_icon_y, window_icon_size, window_icon_size);
388+ window_icon. allocate (window_icon_alloc);
451389 }
452390
453391#if HAS_MUTTER45
@@ -563,45 +501,31 @@ public class Gala.WindowClone : Clutter.Actor {
563501 * position we just freed is immediately filled by the WindowCloneContainer.
564502 */
565503 private Clutter . Actor drag_begin (float click_x, float click_y) {
566- float abs_x, abs_y;
567- float prev_parent_x, prev_parent_y;
568-
569504 prev_parent = get_parent ();
570505 prev_index = prev_parent. get_children (). index (this );
571- prev_parent. get_transformed_position (out prev_parent_x, out prev_parent_y);
572506
573507 var stage = get_stage ();
574508 prev_parent. remove_child (this );
575509 stage. add_child (this );
576510
577511 active_shape. hide ();
578512
579- var scale = window_icon. width / clone. width;
580513 var duration = AnimationsSettings . get_animation_duration (FADE_ANIMATION_DURATION );
581514
582- clone. get_transformed_position (out abs_x, out abs_y);
583- clone. save_easing_state ();
584- clone. set_easing_duration (duration);
585- clone. set_easing_mode (Clutter . AnimationMode . EASE_IN_CUBIC );
586- clone. set_pivot_point ((click_x - abs_x) / clone. width, (click_y - abs_y) / clone. height);
587- clone. set_scale (scale, scale);
588- clone. opacity = 0 ;
589- clone. restore_easing_state ();
590-
591- request_reposition ();
592-
515+ float abs_x, abs_y;
593516 get_transformed_position (out abs_x, out abs_y);
594517
595- set_position (abs_x + prev_parent_x, abs_y + prev_parent_y);
518+ set_position (abs_x, abs_y);
519+ set_pivot_point ((click_x - abs_x) / width, (click_y - abs_y) / height);
596520
597- window_icon . save_easing_state ();
598- window_icon . set_easing_duration (duration);
599- window_icon . set_easing_mode (Clutter . AnimationMode . EASE_IN_OUT_CUBIC );
600- window_icon . set_position (
601- click_x - (abs_x + prev_parent_x) - window_icon . width / 2 ,
602- click_y - (abs_y + prev_parent_y) - window_icon . height / 2
603- );
604- window_icon . restore_easing_state ();
521+ save_easing_state ();
522+ set_easing_duration (duration);
523+ set_easing_mode (EASE_IN_CUBIC );
524+ set_scale ( 0.3 , 0.3 );
525+ opacity = 200 ;
526+ restore_easing_state ();
527+
528+ request_reposition ();
605529
606530 close_button. opacity = 0 ;
607531 window_title. opacity = 0 ;
@@ -742,42 +666,25 @@ public class Gala.WindowClone : Clutter.Actor {
742666 */
743667 private void drag_canceled () {
744668 get_parent (). remove_child (this );
745- prev_parent. insert_child_at_index (this , prev_index);
669+ prev_parent. add_child (this ); // Add above so that it is above while animates back to its place
746670
747671 var duration = AnimationsSettings . get_animation_duration (MultitaskingView . ANIMATION_DURATION );
748672
749- clone. set_pivot_point (0.0f , 0.0f );
750- clone. save_easing_state ();
751- clone. set_easing_duration (duration);
752- clone. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
753- clone. set_scale (1 , 1 );
754- clone. opacity = 255 ;
755- clone. restore_easing_state ();
673+ save_easing_state ();
674+ set_easing_duration (duration);
675+ set_easing_mode (EASE_OUT_QUAD );
676+ set_scale (1 , 1 );
677+ opacity = 255 ;
678+ restore_easing_state ();
756679
757680 request_reposition ();
758681
759- window_icon. save_easing_state ();
760- window_icon. set_easing_duration (duration);
761- window_icon. set_easing_mode (Clutter . AnimationMode . EASE_OUT_QUAD );
762-
763- set_window_icon_position (slot. width, slot. height, monitor_scale_factor);
764- window_icon. restore_easing_state ();
765-
766682 display. set_cursor (Meta . Cursor . DEFAULT );
767- }
768-
769- private void set_window_icon_position (float window_width, float window_height, float scale_factor, bool aligned = true ) {
770- var size = InternalUtils . scale_to_int (WINDOW_ICON_SIZE , scale_factor);
771- var x = (window_width - size) / 2 ;
772- var y = window_height - (size * 0.75f );
773683
774- if (aligned) {
775- x = (int ) Math . round (x);
776- y = (int ) Math . round (y);
777- }
778-
779- window_icon. set_size (size, size);
780- window_icon. set_position (x, y);
684+ Timeout . add (duration, () = > {
685+ prev_parent. set_child_at_index (this , prev_index); // Set the correct index so that correct stacking order is kept
686+ return Source . REMOVE ;
687+ });
781688 }
782689
783690 private static bool is_close_button_on_left () {
0 commit comments