Skip to content

Commit 6c4dce9

Browse files
committed
WindowCloneContainer: Use allocate instead of making windows take slots
1 parent 4b1c578 commit 6c4dce9

File tree

3 files changed

+56
-30
lines changed

3 files changed

+56
-30
lines changed

lib/Gestures/ActorTarget.vala

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

1616
private double[] current_progress;
1717
private double[] current_commit;
18+
private bool[] relayout_actions;
1819
private Gee.List<GestureTarget> targets;
1920

2021
private int ongoing_animations = 0;
2122

2223
construct {
2324
current_progress = new double[GestureAction.N_ACTIONS];
2425
current_commit = new double[GestureAction.N_ACTIONS];
26+
relayout_actions = new bool[GestureAction.N_ACTIONS];
2527
targets = new Gee.ArrayList<GestureTarget> ();
2628

2729
#if HAS_MUTTER46
@@ -38,6 +40,10 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
3840
}
3941
}
4042

43+
public void set_relayout_action (GestureAction action, bool relayout) {
44+
relayout_actions[action] = relayout;
45+
}
46+
4147
public void add_target (GestureTarget target) {
4248
targets.add (target);
4349
sync_target (target);
@@ -88,6 +94,11 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
8894
break;
8995
case UPDATE:
9096
update_progress (action, progress);
97+
98+
if (relayout_actions[action]) {
99+
queue_relayout ();
100+
}
101+
91102
break;
92103
case COMMIT:
93104
commit_progress (action, progress);

src/Widgets/MultitaskingView/WindowClone.vala

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

181181
set_child_below_sibling (window_icon, window_title);
182+
183+
update_targets ();
182184
}
183185

184186
/**
@@ -227,39 +229,13 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
227229
&& window.get_workspace () != window.get_display ().get_workspace_manager ().get_active_workspace ()) || window.minimized;
228230
}
229231

230-
/**
231-
* Animate the window to the given slot
232-
*/
233-
public void take_slot (Mtk.Rectangle rect, bool animate) {
234-
slot = rect;
235-
236-
if (animate) {
237-
save_easing_state ();
238-
set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
239-
set_easing_mode (EASE_OUT_QUAD);
240-
}
241-
242-
update_targets ();
243-
244-
if (animate) {
245-
restore_easing_state ();
246-
}
247-
}
248-
249232
private void update_targets () {
250-
remove_all_targets ();
251-
252-
if (slot == null) {
233+
if (window_icon == null) {
253234
return;
254235
}
255236

256-
var window_rect = window.get_frame_rect ();
257-
var monitor_geometry = window.display.get_monitor_geometry (window.get_monitor ());
237+
remove_all_targets ();
258238

259-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "x", typeof (float), (float) (window_rect.x - monitor_geometry.x), (float) slot.x));
260-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "y", typeof (float), (float) (window_rect.y - monitor_geometry.y), (float) slot.y));
261-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) window_rect.width, (float) slot.width));
262-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "height", typeof (float), (float) window_rect.height, (float) slot.height));
263239
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "shadow-opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
264240
if (should_fade ()) {
265241
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
@@ -275,7 +251,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
275251
}
276252

277253
public override void update_progress (Gala.GestureAction action, double progress) {
278-
if (action != CUSTOM || slot == null || !Meta.Prefs.get_gnome_animations ()) {
254+
if (action != CUSTOM || !Meta.Prefs.get_gnome_animations ()) {
279255
return;
280256
}
281257

src/Widgets/MultitaskingView/WindowCloneContainer.vala

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class Gala.WindowCloneContainer : ActorTarget {
2323

2424
private bool opened = false;
2525

26+
private HashTable<Clutter.Actor, Clutter.ActorBox?> target_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
27+
private HashTable<Clutter.Actor, Clutter.ActorBox?> origin_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
28+
2629
/**
2730
* The window that is currently selected via keyboard shortcuts.
2831
* It is not necessarily the same as the active window.
@@ -36,6 +39,8 @@ public class Gala.WindowCloneContainer : ActorTarget {
3639
construct {
3740
on_items_changed (0, 0, windows.get_n_items ());
3841
windows.items_changed.connect (on_items_changed);
42+
43+
set_relayout_action (MULTITASKING_VIEW, true);
3944
}
4045

4146
private void on_items_changed (uint position, uint removed, uint added) {
@@ -147,8 +152,42 @@ public class Gala.WindowCloneContainer : ActorTarget {
147152
(int) height - padding_top - padding_bottom
148153
};
149154

155+
target_allocations.remove_all ();
156+
origin_allocations.remove_all ();
150157
foreach (var tilable in calculate_grid_placement (area, windows)) {
151-
tilable.clone.take_slot (tilable.rect, !view_toggle);
158+
var geom = wm.get_display ().get_monitor_geometry (tilable.clone.window.get_monitor ());
159+
var rect = tilable.clone.window.get_frame_rect ();
160+
161+
origin_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (rect.x - geom.x, rect.y - geom.y, rect.width, rect.height);
162+
target_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (tilable.rect.x, tilable.rect.y, tilable.rect.width, tilable.rect.height);
163+
}
164+
}
165+
166+
protected override void allocate (Clutter.ActorBox box) {
167+
set_allocation (box);
168+
169+
for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) {
170+
var target_allocation = target_allocations[child];
171+
var origin_allocation = origin_allocations[child];
172+
173+
if (target_allocation == null || origin_allocation == null) {
174+
child.allocate ({0, 0, 0, 0});
175+
continue;
176+
}
177+
178+
if (!animating) {
179+
child.save_easing_state ();
180+
child.set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
181+
child.set_easing_mode (EASE_OUT_QUAD);
182+
}
183+
184+
child.allocate (
185+
origin_allocation.interpolate (target_allocation, get_current_progress (MULTITASKING_VIEW))
186+
);
187+
188+
if (!animating) {
189+
child.restore_easing_state ();
190+
}
152191
}
153192
}
154193

0 commit comments

Comments
 (0)