diff --git a/lib/Gestures/ActorTarget.vala b/lib/Gestures/ActorTarget.vala index 6884fa581..86de059fb 100644 --- a/lib/Gestures/ActorTarget.vala +++ b/lib/Gestures/ActorTarget.vala @@ -15,6 +15,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; @@ -22,6 +23,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 @@ -38,6 +40,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); @@ -88,6 +94,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 4e4967ed5..3fd575e80 100644 --- a/src/Widgets/MultitaskingView/WindowClone.vala +++ b/src/Widgets/MultitaskingView/WindowClone.vala @@ -179,6 +179,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget { add_child (window_icon); set_child_below_sibling (window_icon, window_title); + + update_targets (); } /** @@ -227,39 +229,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)); @@ -275,7 +251,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 708534a41..61a45b3c8 100644 --- a/src/Widgets/MultitaskingView/WindowCloneContainer.vala +++ b/src/Widgets/MultitaskingView/WindowCloneContainer.vala @@ -11,10 +11,7 @@ public class Gala.WindowCloneContainer : ActorTarget { public signal void window_selected (Meta.Window window); public signal void requested_close (); - public int padding_top { get; set; default = 12; } - public int padding_left { get; set; default = 12; } - public int padding_right { get; set; default = 12; } - public int padding_bottom { get; set; default = 12; } + public Mtk.Rectangle area { get; set; } public WindowManager wm { get; construct; } public WindowListModel windows { get; construct; } @@ -23,6 +20,9 @@ public class Gala.WindowCloneContainer : ActorTarget { private bool opened = false; + private HashTable target_allocations = new HashTable (null, null); + private HashTable origin_allocations = new HashTable (null, null); + /** * The window that is currently selected via keyboard shortcuts. * It is not necessarily the same as the active window. @@ -36,6 +36,9 @@ public class Gala.WindowCloneContainer : ActorTarget { construct { on_items_changed (0, 0, windows.get_n_items ()); windows.items_changed.connect (on_items_changed); + + set_relayout_action (MULTITASKING_VIEW, true); + set_relayout_action (SWITCH_WORKSPACE, true); } private void on_items_changed (uint position, uint removed, uint added) { @@ -140,15 +143,53 @@ public class Gala.WindowCloneContainer : ActorTarget { return (int) (seq_b - seq_a); }); - Mtk.Rectangle area = { - padding_left, - padding_top, - (int) width - padding_left - padding_right, - (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); + } + } + + protected override void allocate (Clutter.ActorBox box) { + set_allocation (box); + + var static_windows = StaticWindowContainer.get_instance (wm.get_display ()); + for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) { + if (child is WindowClone && static_windows.is_static (child.window)) { + float x, y; + get_transformed_position (out x, out y); + + var allocation = origin_allocations[child]; + allocation.set_origin (allocation.x1 - x, allocation.y1 - y); + child.allocate (allocation); + continue; + } + + 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 (); + } } } diff --git a/src/Widgets/MultitaskingView/WorkspaceClone.vala b/src/Widgets/MultitaskingView/WorkspaceClone.vala index b6563b6b9..8e7101168 100644 --- a/src/Widgets/MultitaskingView/WorkspaceClone.vala +++ b/src/Widgets/MultitaskingView/WorkspaceClone.vala @@ -167,6 +167,8 @@ public class Gala.WorkspaceClone : ActorTarget { } }); + clip_to_allocation = true; + add_child (background); add_child (window_container); @@ -200,18 +202,31 @@ public class Gala.WorkspaceClone : ActorTarget { var scale = (float)(monitor.height - Utils.scale_to_int (TOP_OFFSET + BOTTOM_OFFSET, monitor_scale)) / monitor.height; var pivot_y = Utils.scale_to_int (TOP_OFFSET, monitor_scale) / (monitor.height - monitor.height * scale); - background.set_pivot_point (0.5f, pivot_y); + background.set_pivot_point (0f, pivot_y); var initial_width = monitor.width; - var target_width = monitor.width * scale + WorkspaceRow.WORKSPACE_GAP * 2; + var target_width = monitor.width * scale; + + var target_height = monitor.height * scale; - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width, (float) target_width)); + add_target (new PropertyTarget (MULTITASKING_VIEW, window_container, "width", typeof (float), (float) target_height, (float) target_width)); + add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width + WorkspaceRow.WORKSPACE_GAP, (float) target_width + WorkspaceRow.WORKSPACE_GAP)); add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-x", typeof (double), 1d, (double) scale)); add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-y", typeof (double), 1d, (double) scale)); - window_container.padding_top = Utils.scale_to_int (TOP_OFFSET, monitor_scale); - window_container.padding_left = window_container.padding_right = (int) (monitor.width - monitor.width * scale) / 2; - window_container.padding_bottom = Utils.scale_to_int (BOTTOM_OFFSET, monitor_scale); + background.x = WorkspaceRow.WORKSPACE_GAP / 2; + window_container.x = WorkspaceRow.WORKSPACE_GAP / 2; + + window_container.area = { + 12, + Utils.scale_to_int (TOP_OFFSET, monitor_scale), + (int) (target_width - 24), + (int) target_height + }; + } + + public override void update_progress (GestureAction action, double progress) { + // background.set_pivot_point (0.5f, 0f); } private void activate (bool close_view) { diff --git a/src/Widgets/MultitaskingView/WorkspaceRow.vala b/src/Widgets/MultitaskingView/WorkspaceRow.vala index 1398a2361..61a56ab56 100644 --- a/src/Widgets/MultitaskingView/WorkspaceRow.vala +++ b/src/Widgets/MultitaskingView/WorkspaceRow.vala @@ -23,12 +23,13 @@ public class Gala.WorkspaceRow : ActorTarget { set_allocation (allocation); double progress = get_current_progress (SWITCH_WORKSPACE); + var monitor_width = display.get_monitor_geometry (display.get_primary_monitor ()).width; int index = 0; for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) { float preferred_width; child.get_preferred_width (-1, null, out preferred_width); - var child_x = (float) Math.round ((progress + index) * (preferred_width + WORKSPACE_GAP)); + var child_x = (float) Math.round ((progress + index) * preferred_width + (monitor_width - preferred_width) / 2); child.allocate_preferred_size (child_x, 0); diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index 5f2f09e4e..c212bbc87 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -120,10 +120,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent model.items_changed.connect (on_items_changed); window_clone_container = new WindowCloneContainer (wm, model, scale, true) { - padding_top = TOP_GAP, - padding_left = BORDER, - padding_right = BORDER, - padding_bottom = BOTTOM_GAP, + area = { BORDER, TOP_GAP, geometry.width - 2 * BORDER, geometry.height - TOP_GAP - BOTTOM_GAP }, width = geometry.width, height = geometry.height, x = geometry.x, diff --git a/src/WindowListModel.vala b/src/WindowListModel.vala index a4c55a343..9a6cfbc0f 100644 --- a/src/WindowListModel.vala +++ b/src/WindowListModel.vala @@ -63,6 +63,8 @@ public class Gala.WindowListModel : Object, ListModel { StaticWindowContainer.get_instance (display).window_changed.connect (check_window); display.window_entered_monitor.connect ((monitor, win) => check_window (win)); + // display.get_workspace_manager ().active_workspace_changed.connect (() => Idle.add_once (check_all)); + notify.connect (check_all); check_all (); @@ -106,10 +108,7 @@ public class Gala.WindowListModel : Object, ListModel { return false; } - if (workspace_filter != null && - (StaticWindowContainer.get_instance (display).is_static (window) || - !window.located_on_workspace (workspace_filter)) - ) { + if (workspace_filter != null && !window.located_on_workspace (workspace_filter)) { return false; }