diff --git a/lib/Gestures/ActorTarget.vala b/lib/Gestures/ActorTarget.vala index 97a287a85..9555a71ca 100644 --- a/lib/Gestures/ActorTarget.vala +++ b/lib/Gestures/ActorTarget.vala @@ -21,6 +21,7 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget { private double[] current_progress; private double[] current_commit; + private bool[] relayout_actions; private Gee.List targets; private int ongoing_animations = 0; @@ -28,6 +29,7 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget { construct { current_progress = new double[GestureAction.N_ACTIONS]; current_commit = new double[GestureAction.N_ACTIONS]; + relayout_actions = new bool[GestureAction.N_ACTIONS]; targets = new Gee.ArrayList (); #if HAS_MUTTER46 @@ -44,6 +46,10 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget { } } + public void set_relayout_action (GestureAction action, bool relayout) { + relayout_actions[action] = relayout; + } + public void add_target (GestureTarget target) { targets.add (target); sync_target (target); @@ -94,6 +100,11 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget { break; case UPDATE: update_progress (action, progress); + + if (relayout_actions[action]) { + queue_relayout (); + } + break; case COMMIT: commit_progress (action, progress); diff --git a/src/Widgets/MultitaskingView/WindowClone.vala b/src/Widgets/MultitaskingView/WindowClone.vala index 421d7c103..992279310 100644 --- a/src/Widgets/MultitaskingView/WindowClone.vala +++ b/src/Widgets/MultitaskingView/WindowClone.vala @@ -176,6 +176,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget { add_child (window_icon); set_child_below_sibling (window_icon, window_title); + + update_targets (); } /** @@ -224,39 +226,13 @@ public class Gala.WindowClone : ActorTarget, RootTarget { && window.get_workspace () != window.get_display ().get_workspace_manager ().get_active_workspace ()) || window.minimized; } - /** - * Animate the window to the given slot - */ - public void take_slot (Mtk.Rectangle rect, bool animate) { - slot = rect; - - if (animate) { - save_easing_state (); - set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); - set_easing_mode (EASE_OUT_QUAD); - } - - update_targets (); - - if (animate) { - restore_easing_state (); - } - } - private void update_targets () { - remove_all_targets (); - - if (slot == null) { + if (window_icon == null) { return; } - var window_rect = window.get_frame_rect (); - var monitor_geometry = window.display.get_monitor_geometry (window.get_monitor ()); + remove_all_targets (); - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "x", typeof (float), (float) (window_rect.x - monitor_geometry.x), (float) slot.x)); - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "y", typeof (float), (float) (window_rect.y - monitor_geometry.y), (float) slot.y)); - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) window_rect.width, (float) slot.width)); - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "height", typeof (float), (float) window_rect.height, (float) slot.height)); add_target (new PropertyTarget (MULTITASKING_VIEW, this, "shadow-opacity", typeof (uint8), (uint8) 0u, (uint8) 255u)); if (should_fade ()) { add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u)); @@ -272,7 +248,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget { } public override void update_progress (Gala.GestureAction action, double progress) { - if (action != CUSTOM || slot == null || !Meta.Prefs.get_gnome_animations ()) { + if (action != CUSTOM || !Meta.Prefs.get_gnome_animations ()) { return; } diff --git a/src/Widgets/MultitaskingView/WindowCloneContainer.vala b/src/Widgets/MultitaskingView/WindowCloneContainer.vala index 8adac200a..2a92a3e3f 100644 --- a/src/Widgets/MultitaskingView/WindowCloneContainer.vala +++ b/src/Widgets/MultitaskingView/WindowCloneContainer.vala @@ -29,10 +29,45 @@ public class Gala.WindowCloneContainer : ActorTarget { */ private unowned WindowClone? current_window = null; + private HashTable target_allocations = new HashTable (null, null); + private HashTable origin_allocations = new HashTable (null, null); + public WindowCloneContainer (WindowManager wm, float monitor_scale, bool overview_mode = false) { Object (wm: wm, monitor_scale: monitor_scale, overview_mode: overview_mode); } + construct { + set_relayout_action (MULTITASKING_VIEW, true); + } + + protected override void allocate (Clutter.ActorBox box) { + set_allocation (box); + + for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) { + var target_allocation = target_allocations[child]; + var origin_allocation = origin_allocations[child]; + + if (target_allocation == null || origin_allocation == null) { + child.allocate ({0, 0, 0, 0}); + continue; + } + + if (!animating) { + child.save_easing_state (); + child.set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); + child.set_easing_mode (EASE_OUT_QUAD); + } + + child.allocate ( + origin_allocation.interpolate (target_allocation, get_current_progress (MULTITASKING_VIEW)) + ); + + if (!animating) { + child.restore_easing_state (); + } + } + } + /** * Create a WindowClone for a Meta.Window and add it to the group * @@ -199,8 +234,14 @@ public class Gala.WindowCloneContainer : ActorTarget { (int) height - padding_top - padding_bottom }; + target_allocations.remove_all (); + origin_allocations.remove_all (); foreach (var tilable in calculate_grid_placement (area, windows)) { - tilable.clone.take_slot (tilable.rect, !view_toggle); + var geom = wm.get_display ().get_monitor_geometry (tilable.clone.window.get_monitor ()); + var rect = tilable.clone.window.get_frame_rect (); + + origin_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (rect.x - geom.x, rect.y - geom.y, rect.width, rect.height); + target_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (tilable.rect.x, tilable.rect.y, tilable.rect.width, tilable.rect.height); } }