@@ -20,8 +20,9 @@ namespace Gala {
2020 private const double ANIMATION_OPACITY_STEP_INCREMENT = 4.0 ;
2121 private const double ANIMATION_MIN_WAKEUP_INTERVAL = 1.0 ;
2222
23- public signal void changed ();
2423 public signal void loaded ();
24+ public signal void invalidate ();
25+ public signal void changed ();
2526
2627 public Meta . Display display { get ; construct; }
2728 public int monitor_index { get ; construct; }
@@ -35,6 +36,8 @@ namespace Gala {
3536 private Gee . HashMap<string,ulong> file_watches;
3637 private Cancellable cancellable;
3738 private uint update_animation_timeout_id = 0 ;
39+ private string ? previous_animation_file = null ;
40+ private double previous_animation_progress = 0.0 ;
3841
3942 private Gnome . WallClock clock;
4043 private ulong clock_timezone_handler = 0 ;
@@ -133,7 +136,7 @@ namespace Gala {
133136 if (changed_file == filename) {
134137 var image_cache = Meta . BackgroundImageCache . get_default ();
135138 image_cache. purge (File . new_for_path (changed_file));
136- changed ();
139+ invalidate ();
137140 }
138141 });
139142 }
@@ -148,12 +151,33 @@ namespace Gala {
148151 private void finish_animation (string [] files ) {
149152 set_loaded ();
150153
151- if (files. length > 1 )
154+ string ? new_last_animation_file = null ;
155+
156+ if (files. length > 1 ) {
152157 background. set_blend (File . new_for_path (files[0 ]), File . new_for_path (files[1 ]), animation. transition_progress, style);
153- else if (files. length > 0 )
158+ new_last_animation_file = files[1 ];
159+ } else if (files. length == 1 ) {
154160 background. set_file (File . new_for_path (files[0 ]), style);
155- else
161+ new_last_animation_file = files[0 ];
162+ } else {
156163 background. set_file (null , style);
164+ new_last_animation_file = null ;
165+ }
166+
167+ if (previous_animation_file != new_last_animation_file) {
168+ previous_animation_file = new_last_animation_file;
169+ previous_animation_progress = 0.0 ;
170+ }
171+
172+ if (
173+ animation. transition_progress >= 0.25 && previous_animation_progress < 0.25 ||
174+ animation. transition_progress >= 0.5 && previous_animation_progress < 0.5 ||
175+ animation. transition_progress >= 0.75 && previous_animation_progress < 0.75
176+ ) {
177+ changed ();
178+ }
179+
180+ previous_animation_progress = animation. transition_progress;
157181
158182 queue_update_animation ();
159183 }
@@ -206,10 +230,9 @@ namespace Gala {
206230 if (interval > uint32 . MAX )
207231 return ;
208232
209- update_animation_timeout_id = Timeout . add (interval, () = > {
233+ update_animation_timeout_id = Timeout . add_once (interval, () = > {
210234 update_animation_timeout_id = 0 ;
211235 update_animation ();
212- return Source . REMOVE ;
213236 });
214237 }
215238
@@ -259,7 +282,7 @@ namespace Gala {
259282 }
260283
261284 private void settings_changed () {
262- changed ();
285+ invalidate ();
263286 }
264287 }
265288}
0 commit comments