Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/Gestures/ActorTarget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {

private double[] current_progress;
private double[] current_commit;
private bool[] relayout_actions;
private Gee.List<GestureTarget> targets;

private int ongoing_animations = 0;

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<GestureTarget> ();

#if HAS_MUTTER46
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 5 additions & 29 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
add_child (window_icon);

set_child_below_sibling (window_icon, window_title);

update_targets ();
}

/**
Expand Down Expand Up @@ -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));
Expand All @@ -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;
}

Expand Down
43 changes: 42 additions & 1 deletion src/Widgets/MultitaskingView/WindowCloneContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,45 @@ public class Gala.WindowCloneContainer : ActorTarget {
*/
private unowned WindowClone? current_window = null;

private HashTable<Clutter.Actor, Clutter.ActorBox?> target_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
private HashTable<Clutter.Actor, Clutter.ActorBox?> origin_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (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
*
Expand Down Expand Up @@ -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);
}
}

Expand Down