Skip to content

Commit

Permalink
Merge branch 'master' into lenemter/idk-what-im-doing
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Sep 29, 2023
2 parents 5cb457e + f771b2a commit 918004f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
40 changes: 21 additions & 19 deletions src/Background/BackgroundSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ namespace Gala {

internal int use_count { get; set; default = 0; }

private Gee.HashMap<int,Background> backgrounds;
private GLib.HashTable<int, Background> backgrounds;
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));
}

construct {
backgrounds = new Gee.HashMap<int,Background> ();
backgrounds = new GLib.HashTable<int, Background> (GLib.direct_hash, GLib.direct_equal);
hash_cache = new uint[OPTIONS.length];

unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (monitors_changed);

// unfortunately the settings sometimes tend to fire random changes even though
Expand Down Expand Up @@ -77,17 +78,16 @@ namespace Gala {
var n = display.get_n_monitors ();
var i = 0;

foreach (var background in backgrounds.values) {
backgrounds.foreach_remove ((hash, background) => {
if (i++ < n) {
background.update_resolution ();
continue;
return false;
} else {
background.changed.disconnect (background_changed);
background.destroy ();
return true;
}

background.changed.disconnect (background_changed);
background.destroy ();
// TODO can we remove from a list while iterating?
backgrounds.unset (i);
}
});
}

public Background get_background (int monitor_index) {
Expand All @@ -105,13 +105,14 @@ namespace Gala {
if (filename == null || !filename.has_suffix (".xml"))
monitor_index = 0;

if (!backgrounds.has_key (monitor_index)) {
var background = new Background (display, monitor_index, filename, this, (GDesktop.BackgroundStyle) style);
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);
backgrounds[monitor_index] = background;
backgrounds.insert (monitor_index, background);
}

return backgrounds[monitor_index];
return background;
}

private string get_background_path () {
Expand All @@ -135,17 +136,18 @@ namespace Gala {
private void background_changed (Background background) {
background.changed.disconnect (background_changed);
background.destroy ();
backgrounds.unset (background.monitor_index);
backgrounds.remove (background.monitor_index);
}

public void destroy () {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.disconnect (monitors_changed);
monitor_manager = null;

foreach (var background in backgrounds.values) {
backgrounds.foreach_remove ((hash, background) => {
background.changed.disconnect (background_changed);
background.destroy ();
}
return true;
});
}
}
}
4 changes: 0 additions & 4 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,6 @@ namespace Gala {
// Most things inside this "later" depend on GTK. We get segfaults if we try to do GTK stuff before the window manager
// is initialized, so we hold this stuff off until we're ready to draw
laters.add (Meta.LaterType.BEFORE_REDRAW, () => {
string[] args = {};
unowned string[] _args = args;
Gtk.init (ref _args);

accent_color_manager = new AccentColorManager ();

// initialize plugins and add default components if no plugin overrides them
Expand Down

0 comments on commit 918004f

Please sign in to comment.