Skip to content

Commit a03cdbe

Browse files
committed
Use PropertyAnimator for unmaximize animation
1 parent 2208633 commit a03cdbe

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

src/WindowManager.vala

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,26 +1492,27 @@ namespace Gala {
14921492

14931493
ui_group.add_child (latest_window_snapshot);
14941494

1495-
var scale_x = (float) ew / old_rect_size_change.width;
1496-
var scale_y = (float) eh / old_rect_size_change.height;
1497-
1498-
latest_window_snapshot.save_easing_state ();
1499-
latest_window_snapshot.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1500-
latest_window_snapshot.set_easing_duration (duration);
1501-
latest_window_snapshot.set_position (ex, ey);
1502-
latest_window_snapshot.set_scale (scale_x, scale_y);
1503-
latest_window_snapshot.opacity = 0U;
1504-
latest_window_snapshot.restore_easing_state ();
1505-
1506-
ulong unmaximize_old_handler_id = 0;
1507-
unmaximize_old_handler_id = latest_window_snapshot.transition_stopped.connect ((snapshot, name, is_finished) => {
1508-
snapshot.disconnect (unmaximize_old_handler_id);
1495+
var scale_x = (double) ew / old_rect_size_change.width;
1496+
var scale_y = (double) eh / old_rect_size_change.height;
15091497

1510-
unowned var parent = snapshot.get_parent ();
1511-
if (parent != null) {
1512-
parent.remove_child (snapshot);
1498+
new PropertyAnimator (
1499+
latest_window_snapshot,
1500+
duration,
1501+
Clutter.AnimationMode.EASE_IN_OUT_QUAD,
1502+
{
1503+
{ "x", typeof (float), null, (float) ex },
1504+
{ "y", typeof (float), null, (float) ey },
1505+
{ "scale-x", typeof (double), null, scale_x },
1506+
{ "scale-y", typeof (double), null, scale_y },
1507+
{ "opacity", typeof (uint), null, 0u }
1508+
},
1509+
(actor) => {
1510+
unowned var parent = actor.get_parent ();
1511+
if (parent != null) {
1512+
parent.remove_child (actor);
1513+
}
15131514
}
1514-
});
1515+
);
15151516

15161517
latest_window_snapshot = null;
15171518

@@ -1522,21 +1523,28 @@ namespace Gala {
15221523

15231524
actor.set_pivot_point (0.0f, 0.0f);
15241525
actor.set_position (ex - real_actor_offset_x, ey - real_actor_offset_y);
1525-
actor.set_translation (-ex + offset_x * (1.0f / scale_x - 1.0f) + old_rect_size_change.x, -ey + offset_y * (1.0f / scale_y - 1.0f) + old_rect_size_change.y, 0.0f);
1526+
actor.set_translation (
1527+
(float) (-ex + offset_x * (1.0f / scale_x - 1.0f) + old_rect_size_change.x),
1528+
(float) (-ey + offset_y * (1.0f / scale_y - 1.0f) + old_rect_size_change.y),
1529+
0.0f
1530+
);
15261531
actor.set_scale (1.0f / scale_x, 1.0f / scale_y);
15271532

1528-
actor.save_easing_state ();
1529-
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD);
1530-
actor.set_easing_duration (duration);
1531-
actor.set_scale (1.0f, 1.0f);
1532-
actor.set_translation (0.0f, 0.0f, 0.0f);
1533-
actor.restore_easing_state ();
1534-
1535-
ulong handler_id = 0UL;
1536-
handler_id = actor.transitions_completed.connect (() => {
1537-
actor.disconnect (handler_id);
1538-
unmaximizing.remove (actor);
1539-
});
1533+
new PropertyAnimator (
1534+
actor,
1535+
duration,
1536+
Clutter.AnimationMode.EASE_IN_OUT_QUAD,
1537+
{
1538+
{ "scale-x", typeof (double), null, 1.0 },
1539+
{ "scale-y", typeof (double), null, 1.0 },
1540+
{ "translation-x", typeof (float), null, 0.0f },
1541+
{ "translation-y", typeof (float), null, 0.0f },
1542+
{ "translation-z", typeof (float), null, 0.0f },
1543+
},
1544+
(actor) => {
1545+
unmaximizing.remove ((Meta.WindowActor) actor);
1546+
}
1547+
);
15401548
}
15411549

15421550
private void move_window_to_next_ws (Meta.Window window) {

0 commit comments

Comments
 (0)