Skip to content

Commit 5e6c7ec

Browse files
committed
Fix panel coloring with animated wallpapers
1 parent 68b2863 commit 5e6c7ec

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

src/Background/Background.vala

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Background/BackgroundManager.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
117117
unowned var display = wm.get_display ();
118118

119119
var background = background_source.get_background (monitor_index);
120+
background.changed.connect (() => changed ());
121+
120122
var background_actor = new Meta.BackgroundActor (display, monitor_index);
121123

122124
unowned var content = (Meta.BackgroundContent) background_actor.content;
@@ -138,7 +140,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
138140
}
139141

140142
ulong changed_handler = 0;
141-
changed_handler = background.changed.connect (() => {
143+
changed_handler = background.invalidate.connect (() => {
142144
background.disconnect (changed_handler);
143145
changed_handler = 0;
144146
update_background_actor ();

src/Background/BackgroundSource.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace Gala {
9696
background.update_resolution ();
9797
return false;
9898
} else {
99-
background.changed.disconnect (background_changed);
99+
background.invalidate.disconnect (background_invalidated);
100100
background.destroy ();
101101
return true;
102102
}
@@ -121,7 +121,7 @@ namespace Gala {
121121
var background = backgrounds.lookup (monitor_index);
122122
if (background == null) {
123123
background = new Background (display, monitor_index, filename, this, (GDesktop.BackgroundStyle) style);
124-
background.changed.connect (background_changed);
124+
background.invalidate.connect (background_invalidated);
125125
backgrounds.insert (monitor_index, background);
126126
}
127127

@@ -146,8 +146,8 @@ namespace Gala {
146146
return uri;
147147
}
148148

149-
private void background_changed (Background background) {
150-
background.changed.disconnect (background_changed);
149+
private void background_invalidated (Background background) {
150+
background.invalidate.disconnect (background_invalidated);
151151
background.destroy ();
152152
backgrounds.remove (background.monitor_index);
153153
}
@@ -157,7 +157,7 @@ namespace Gala {
157157
monitor_manager = null;
158158

159159
backgrounds.foreach_remove ((hash, background) => {
160-
background.changed.disconnect (background_changed);
160+
background.invalidate.disconnect (background_invalidated);
161161
background.destroy ();
162162
return true;
163163
});

0 commit comments

Comments
 (0)