Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/Background/Background.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ namespace Gala {
private const double ANIMATION_OPACITY_STEP_INCREMENT = 4.0;
private const double ANIMATION_MIN_WAKEUP_INTERVAL = 1.0;

public signal void changed ();
public signal void loaded ();
public signal void invalidate ();
public signal void changed ();

public Meta.Display display { get; construct; }
public int monitor_index { get; construct; }
Expand All @@ -35,6 +36,8 @@ namespace Gala {
private Gee.HashMap<string,ulong> file_watches;
private Cancellable cancellable;
private uint update_animation_timeout_id = 0;
private string? previous_animation_file = null;
private double previous_animation_progress = 0.0;

private Gnome.WallClock clock;
private ulong clock_timezone_handler = 0;
Expand Down Expand Up @@ -133,7 +136,7 @@ namespace Gala {
if (changed_file == filename) {
var image_cache = Meta.BackgroundImageCache.get_default ();
image_cache.purge (File.new_for_path (changed_file));
changed ();
invalidate ();
}
});
}
Expand All @@ -148,12 +151,33 @@ namespace Gala {
private void finish_animation (string[] files) {
set_loaded ();

if (files.length > 1)
string? new_last_animation_file = null;

if (files.length > 1) {
background.set_blend (File.new_for_path (files[0]), File.new_for_path (files[1]), animation.transition_progress, style);
else if (files.length > 0)
new_last_animation_file = files[1];
} else if (files.length == 1) {
background.set_file (File.new_for_path (files[0]), style);
else
new_last_animation_file = files[0];
} else {
background.set_file (null, style);
new_last_animation_file = null;
}

if (previous_animation_file != new_last_animation_file) {
previous_animation_file = new_last_animation_file;
previous_animation_progress = 0.0;
}

if (
animation.transition_progress >= 0.25 && previous_animation_progress < 0.25 ||
animation.transition_progress >= 0.5 && previous_animation_progress < 0.5 ||
animation.transition_progress >= 0.75 && previous_animation_progress < 0.75
) {
changed ();
}

previous_animation_progress = animation.transition_progress;

queue_update_animation ();
}
Expand Down Expand Up @@ -206,10 +230,9 @@ namespace Gala {
if (interval > uint32.MAX)
return;

update_animation_timeout_id = Timeout.add (interval, () => {
update_animation_timeout_id = Timeout.add_once (interval, () => {
update_animation_timeout_id = 0;
update_animation ();
return Source.REMOVE;
});
}

Expand Down Expand Up @@ -259,7 +282,7 @@ namespace Gala {
}

private void settings_changed () {
changed ();
invalidate ();
}
}
}
4 changes: 3 additions & 1 deletion src/Background/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
unowned var display = wm.get_display ();

var background = background_source.get_background (monitor_index);
background.changed.connect (() => changed ());

var background_actor = new Meta.BackgroundActor (display, monitor_index);

unowned var content = (Meta.BackgroundContent) background_actor.content;
Expand All @@ -145,7 +147,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
}

ulong changed_handler = 0;
changed_handler = background.changed.connect (() => {
changed_handler = background.invalidate.connect (() => {
background.disconnect (changed_handler);
changed_handler = 0;
update_background_actor ();
Expand Down
10 changes: 5 additions & 5 deletions src/Background/BackgroundSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace Gala {
background.update_resolution ();
return false;
} else {
background.changed.disconnect (background_changed);
background.invalidate.disconnect (background_invalidated);
background.destroy ();
return true;
}
Expand All @@ -121,7 +121,7 @@ namespace Gala {
var background = backgrounds.lookup (monitor_index);
if (background == null) {
background = new Background (display, monitor_index, filename, this, (GDesktop.BackgroundStyle) style);
background.changed.connect (background_changed);
background.invalidate.connect (background_invalidated);
backgrounds.insert (monitor_index, background);
}

Expand All @@ -146,8 +146,8 @@ namespace Gala {
return uri;
}

private void background_changed (Background background) {
background.changed.disconnect (background_changed);
private void background_invalidated (Background background) {
background.invalidate.disconnect (background_invalidated);
background.destroy ();
backgrounds.remove (background.monitor_index);
}
Expand All @@ -157,7 +157,7 @@ namespace Gala {
monitor_manager = null;

backgrounds.foreach_remove ((hash, background) => {
background.changed.disconnect (background_changed);
background.invalidate.disconnect (background_invalidated);
background.destroy ();
return true;
});
Expand Down