Skip to content

Commit 2208633

Browse files
committed
WindowManager: use PropertyAnimator for minimize animation
1 parent 70f4531 commit 2208633

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

src/WindowManager.vala

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,20 +1073,14 @@ namespace Gala {
10731073
}
10741074

10751075
public override void minimize (Meta.WindowActor actor) {
1076-
if (!Meta.Prefs.get_gnome_animations () ||
1077-
actor.get_meta_window ().window_type != Meta.WindowType.NORMAL) {
1076+
if (!Utils.get_window_is_normal (actor.meta_window)) {
10781077
minimize_completed (actor);
10791078
return;
10801079
}
10811080

1082-
var duration = AnimationDuration.HIDE;
1083-
10841081
kill_window_effects (actor);
10851082
minimizing.add (actor);
10861083

1087-
int width, height;
1088-
get_display ().get_size (out width, out height);
1089-
10901084
Mtk.Rectangle icon = {};
10911085
if (actor.get_meta_window ().get_icon_geometry (out icon)) {
10921086
// Fix icon position and size according to ui scaling factor.
@@ -1096,45 +1090,43 @@ namespace Gala {
10961090
icon.width = Utils.scale_to_int (icon.width, ui_scale);
10971091
icon.height = Utils.scale_to_int (icon.height, ui_scale);
10981092

1099-
float scale_x = (float)icon.width / actor.width;
1100-
float scale_y = (float)icon.height / actor.height;
1093+
var scale_x = (double) icon.width / actor.width;
1094+
var scale_y = (double) icon.height / actor.height;
11011095
float anchor_x = (float)(actor.x - icon.x) / (icon.width - actor.width);
11021096
float anchor_y = (float)(actor.y - icon.y) / (icon.height - actor.height);
11031097
actor.set_pivot_point (anchor_x, anchor_y);
11041098

1105-
actor.save_easing_state ();
1106-
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_EXPO);
1107-
actor.set_easing_duration (duration);
1108-
actor.set_scale (scale_x, scale_y);
1109-
actor.opacity = 0U;
1110-
actor.restore_easing_state ();
1111-
1112-
ulong minimize_handler_id = 0UL;
1113-
minimize_handler_id = actor.transitions_completed.connect (() => {
1114-
actor.disconnect (minimize_handler_id);
1115-
minimize_completed (actor);
1116-
minimizing.remove (actor);
1117-
});
1118-
1099+
new PropertyAnimator (
1100+
actor,
1101+
AnimationDuration.HIDE,
1102+
Clutter.AnimationMode.EASE_IN_EXPO,
1103+
{
1104+
{ "scale-x", typeof (double), null, scale_x },
1105+
{ "scale-y", typeof (double), null, scale_y },
1106+
{ "opacity", typeof (uint), null, 0u },
1107+
},
1108+
(actor) => {
1109+
minimize_completed ((Meta.WindowActor) actor);
1110+
minimizing.remove ((Meta.WindowActor) actor);
1111+
}
1112+
);
11191113
} else {
11201114
actor.set_pivot_point (0.5f, 1.0f);
11211115

1122-
actor.save_easing_state ();
1123-
actor.set_easing_mode (Clutter.AnimationMode.EASE_IN_EXPO);
1124-
actor.set_easing_duration (duration);
1125-
actor.set_scale (0.0f, 0.0f);
1126-
actor.opacity = 0U;
1127-
actor.restore_easing_state ();
1128-
1129-
ulong minimize_handler_id = 0UL;
1130-
minimize_handler_id = actor.transitions_completed.connect (() => {
1131-
actor.disconnect (minimize_handler_id);
1132-
actor.set_pivot_point (0.0f, 0.0f);
1133-
actor.set_scale (1.0f, 1.0f);
1134-
actor.opacity = 255U;
1135-
minimize_completed (actor);
1136-
minimizing.remove (actor);
1137-
});
1116+
new PropertyAnimator (
1117+
actor,
1118+
AnimationDuration.HIDE,
1119+
Clutter.AnimationMode.EASE_IN_EXPO,
1120+
{
1121+
{ "scale-x", typeof (double), null, 0.0 },
1122+
{ "scale-y", typeof (double), null, 0.0 },
1123+
{ "opacity", typeof (uint), null, 0u },
1124+
},
1125+
(actor) => {
1126+
minimize_completed ((Meta.WindowActor) actor);
1127+
minimizing.remove ((Meta.WindowActor) actor);
1128+
}
1129+
);
11381130
}
11391131
}
11401132

0 commit comments

Comments
 (0)