Skip to content

Commit 8e35e27

Browse files
committed
WindowCloneContainer: Use allocate instead of making windows take slots
1 parent 3e606b1 commit 8e35e27

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

lib/Gestures/ActorTarget.vala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
2121

2222
private double[] current_progress;
2323
private double[] current_commit;
24+
private bool[] relayout_actions;
2425
private Gee.List<GestureTarget> targets;
2526

2627
private int ongoing_animations = 0;
2728

2829
construct {
2930
current_progress = new double[GestureAction.N_ACTIONS];
3031
current_commit = new double[GestureAction.N_ACTIONS];
32+
relayout_actions = new bool[GestureAction.N_ACTIONS];
3133
targets = new Gee.ArrayList<GestureTarget> ();
3234

3335
#if HAS_MUTTER46
@@ -44,6 +46,10 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
4446
}
4547
}
4648

49+
public void set_relayout_action (GestureAction action, bool relayout) {
50+
relayout_actions[action] = relayout;
51+
}
52+
4753
public void add_target (GestureTarget target) {
4854
targets.add (target);
4955
sync_target (target);
@@ -94,6 +100,11 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
94100
break;
95101
case UPDATE:
96102
update_progress (action, progress);
103+
104+
if (relayout_actions[action]) {
105+
queue_relayout ();
106+
}
107+
97108
break;
98109
case COMMIT:
99110
commit_progress (action, progress);

src/Widgets/MultitaskingView/WindowClone.vala

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
176176
add_child (window_icon);
177177

178178
set_child_below_sibling (window_icon, window_title);
179+
180+
update_targets ();
179181
}
180182

181183
/**
@@ -224,39 +226,13 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
224226
&& window.get_workspace () != window.get_display ().get_workspace_manager ().get_active_workspace ()) || window.minimized;
225227
}
226228

227-
/**
228-
* Animate the window to the given slot
229-
*/
230-
public void take_slot (Mtk.Rectangle rect, bool animate) {
231-
slot = rect;
232-
233-
if (animate) {
234-
save_easing_state ();
235-
set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
236-
set_easing_mode (EASE_OUT_QUAD);
237-
}
238-
239-
update_targets ();
240-
241-
if (animate) {
242-
restore_easing_state ();
243-
}
244-
}
245-
246229
private void update_targets () {
247-
remove_all_targets ();
248-
249-
if (slot == null) {
230+
if (window_icon == null) {
250231
return;
251232
}
252233

253-
var window_rect = window.get_frame_rect ();
254-
var monitor_geometry = window.display.get_monitor_geometry (window.get_monitor ());
234+
remove_all_targets ();
255235

256-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "x", typeof (float), (float) (window_rect.x - monitor_geometry.x), (float) slot.x));
257-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "y", typeof (float), (float) (window_rect.y - monitor_geometry.y), (float) slot.y));
258-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) window_rect.width, (float) slot.width));
259-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "height", typeof (float), (float) window_rect.height, (float) slot.height));
260236
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "shadow-opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
261237
if (should_fade ()) {
262238
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
@@ -272,7 +248,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
272248
}
273249

274250
public override void update_progress (Gala.GestureAction action, double progress) {
275-
if (action != CUSTOM || slot == null || !Meta.Prefs.get_gnome_animations ()) {
251+
if (action != CUSTOM || !Meta.Prefs.get_gnome_animations ()) {
276252
return;
277253
}
278254

src/Widgets/MultitaskingView/WindowCloneContainer.vala

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,45 @@ public class Gala.WindowCloneContainer : ActorTarget {
2929
*/
3030
private unowned WindowClone? current_window = null;
3131

32+
private HashTable<Clutter.Actor, Clutter.ActorBox?> target_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
33+
private HashTable<Clutter.Actor, Clutter.ActorBox?> origin_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
34+
3235
public WindowCloneContainer (WindowManager wm, float monitor_scale, bool overview_mode = false) {
3336
Object (wm: wm, monitor_scale: monitor_scale, overview_mode: overview_mode);
3437
}
3538

39+
construct {
40+
set_relayout_action (MULTITASKING_VIEW, true);
41+
}
42+
43+
protected override void allocate (Clutter.ActorBox box) {
44+
set_allocation (box);
45+
46+
for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) {
47+
var target_allocation = target_allocations[child];
48+
var origin_allocation = origin_allocations[child];
49+
50+
if (target_allocation == null || origin_allocation == null) {
51+
child.allocate ({0, 0, 0, 0});
52+
continue;
53+
}
54+
55+
if (!animating) {
56+
child.save_easing_state ();
57+
child.set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
58+
child.set_easing_mode (EASE_OUT_QUAD);
59+
}
60+
61+
child.allocate (
62+
origin_allocation.interpolate (target_allocation, get_current_progress (MULTITASKING_VIEW))
63+
);
64+
65+
if (!animating) {
66+
child.restore_easing_state ();
67+
}
68+
}
69+
}
70+
3671
/**
3772
* Create a WindowClone for a Meta.Window and add it to the group
3873
*
@@ -199,8 +234,14 @@ public class Gala.WindowCloneContainer : ActorTarget {
199234
(int) height - padding_top - padding_bottom
200235
};
201236

237+
target_allocations.remove_all ();
238+
origin_allocations.remove_all ();
202239
foreach (var tilable in calculate_grid_placement (area, windows)) {
203-
tilable.clone.take_slot (tilable.rect, !view_toggle);
240+
var geom = wm.get_display ().get_monitor_geometry (tilable.clone.window.get_monitor ());
241+
var rect = tilable.clone.window.get_frame_rect ();
242+
243+
origin_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (rect.x - geom.x, rect.y - geom.y, rect.width, rect.height);
244+
target_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (tilable.rect.x, tilable.rect.y, tilable.rect.width, tilable.rect.height);
204245
}
205246
}
206247

0 commit comments

Comments
 (0)