diff --git a/src/Background/BackgroundCache.vala b/src/Background/BackgroundCache.vala index 03b63188..2de0969e 100644 --- a/src/Background/BackgroundCache.vala +++ b/src/Background/BackgroundCache.vala @@ -29,7 +29,7 @@ namespace Gala { public signal void file_changed (string filename); private Gee.HashMap file_monitors; - private Gee.HashMap background_sources; + private BackgroundSource background_source; private Animation animation; @@ -39,7 +39,6 @@ namespace Gala { construct { file_monitors = new Gee.HashMap (); - background_sources = new Gee.HashMap (); } public void monitor_file (string filename) { @@ -83,25 +82,19 @@ namespace Gala { return animation; } - public BackgroundSource get_background_source (Meta.Display display, string settings_schema) { - var background_source = background_sources[settings_schema]; + public BackgroundSource get_background_source (Meta.Display display) { if (background_source == null) { - background_source = new BackgroundSource (display, settings_schema); + background_source = new BackgroundSource (display); background_source.use_count = 1; - background_sources[settings_schema] = background_source; } else background_source.use_count++; return background_source; } - public void release_background_source (string settings_schema) { - if (background_sources.has_key (settings_schema)) { - var source = background_sources[settings_schema]; - if (--source.use_count == 0) { - background_sources.unset (settings_schema); - source.destroy (); - } + public void release_background_source () { + if (--background_source.use_count == 0) { + background_source.destroy (); } } } diff --git a/src/Background/BackgroundManager.vala b/src/Background/BackgroundManager.vala index fd1d30fe..88300f26 100644 --- a/src/Background/BackgroundManager.vala +++ b/src/Background/BackgroundManager.vala @@ -17,7 +17,6 @@ namespace Gala { public class BackgroundManager : Meta.BackgroundGroup { - private const string GNOME_BACKGROUND_SCHEMA = "org.gnome.desktop.background"; private const string GALA_BACKGROUND_SCHEMA = "io.elementary.desktop.background"; private const string DIM_WALLPAPER_KEY = "dim-wallpaper-in-dark-style"; private const double DIM_OPACITY = 0.55; @@ -46,14 +45,14 @@ namespace Gala { } construct { - background_source = BackgroundCache.get_default ().get_background_source (display, GNOME_BACKGROUND_SCHEMA); + background_source = BackgroundCache.get_default ().get_background_source (display); background_actor = create_background_actor (); destroy.connect (on_destroy); } private void on_destroy () { - BackgroundCache.get_default ().release_background_source (GNOME_BACKGROUND_SCHEMA); + BackgroundCache.get_default ().release_background_source (); background_source = null; if (new_background_actor != null) { diff --git a/src/Background/BackgroundSource.vala b/src/Background/BackgroundSource.vala index 46f16577..f9829bc5 100644 --- a/src/Background/BackgroundSource.vala +++ b/src/Background/BackgroundSource.vala @@ -39,8 +39,8 @@ namespace Gala { private uint[] hash_cache; private Meta.MonitorManager? monitor_manager; - public BackgroundSource (Meta.Display display, string settings_schema) { - Object (display: display, settings: new Settings (settings_schema)); + public BackgroundSource (Meta.Display display) { + Object (display: display); } construct { @@ -50,6 +50,8 @@ namespace Gala { monitor_manager = display.get_context ().get_backend ().get_monitor_manager (); monitor_manager.monitors_changed.connect (monitors_changed); + settings = new Settings ("org.gnome.desktop.background"); + // unfortunately the settings sometimes tend to fire random changes even though // nothing actually happened. The code below is used to prevent us from spamming // new actors all the time, which lead to some problems in other areas of the code