Skip to content

Commit

Permalink
Remove workspace-switcher-background key (#1798)
Browse files Browse the repository at this point in the history
Co-authored-by: Danielle Foré <[email protected]>
  • Loading branch information
lenemter and danirabbit authored Nov 9, 2023
1 parent c58c84a commit 0cc9a04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 63 deletions.
2 changes: 1 addition & 1 deletion data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
</key>
<key type="s" name="workspace-switcher-background">
<default>''</default>
<summary>Background-image used in the workspace-switcher</summary>
<summary>DEPRECATED: This key is deprecated and ignored.</summary>
</key>
</schema>

Expand Down
88 changes: 26 additions & 62 deletions src/Background/SystemBackground.vala
Original file line number Diff line number Diff line change
@@ -1,72 +1,36 @@
//
// Copyright (C) 2014 Tom Beckmann
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
/*
* Copyright 2014 Tom Beckmann
* Copyright 2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace Gala {
public class SystemBackground : GLib.Object {
private const Clutter.Color DEFAULT_BACKGROUND_COLOR = { 0x2e, 0x34, 0x36, 0xff };
public class Gala.SystemBackground : GLib.Object {
private const Clutter.Color DEFAULT_BACKGROUND_COLOR = { 0x2e, 0x34, 0x36, 0xff };

static Meta.Background? system_background = null;
public Meta.BackgroundActor background_actor { get; construct; }
public Meta.BackgroundActor background_actor { get; construct; }

public SystemBackground (Meta.Display display) {
Object (background_actor: new Meta.BackgroundActor (display, 0));
}

construct {
File? background_file = null;
var appearance_settings = new GLib.Settings (Config.SCHEMA + ".appearance");
var custom_path = appearance_settings.get_string ("workspace-switcher-background");
if (custom_path != "" && FileUtils.test (custom_path, FileTest.IS_REGULAR)) {
background_file = GLib.File.new_for_path (custom_path);
}

if (system_background == null) {
system_background = new Meta.Background (background_actor.meta_display);
system_background.set_color (DEFAULT_BACKGROUND_COLOR);
if (background_file != null) {
system_background.set_file (background_file, GDesktop.BackgroundStyle.WALLPAPER);
}
}
private static Meta.Background? system_background = null;

((Meta.BackgroundContent)background_actor.content).background = system_background;
public SystemBackground (Meta.Display display) {
Object (background_actor: new Meta.BackgroundActor (display, 0));
}

if (background_file != null) {
var cache = Meta.BackgroundImageCache.get_default ();
var image = cache.load (background_file);
if (image.is_loaded ()) {
image = null;
} else {
ulong handler = 0;
handler = image.loaded.connect (() => {
image.disconnect (handler);
image = null;
});
}
}
construct {
if (system_background == null) {
system_background = new Meta.Background (background_actor.meta_display);
system_background.set_color (DEFAULT_BACKGROUND_COLOR);
}

public static void refresh () {
// Meta.Background.refresh_all does not refresh backgrounds with the WALLPAPER style.
// (Last tested with mutter 3.28)
// As a workaround, re-apply the current color again to force the wallpaper texture
// to be rendered from scratch.
if (system_background != null) {
system_background.set_color (DEFAULT_BACKGROUND_COLOR);
}
((Meta.BackgroundContent) background_actor.content).background = system_background;
}

public static void refresh () {
// Meta.Background.refresh_all does not refresh backgrounds with the WALLPAPER style.
// (Last tested with mutter 3.28)
// As a workaround, re-apply the current color again to force the wallpaper texture
// to be rendered from scratch.
if (system_background != null) {
system_background.set_color (DEFAULT_BACKGROUND_COLOR);
}
}
}

0 comments on commit 0cc9a04

Please sign in to comment.