From 947cd78da97748fbb4b2e79997fa2710772a943f Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Tue, 24 Sep 2024 17:13:52 +0200 Subject: [PATCH] Move ColorInformation to Background --- background/Background.vala | 17 +++++++++++++---- background/BackgroundManager.vala | 2 +- background/Utils.vala | 11 +---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/background/Background.vala b/background/Background.vala index 0108ee5bc..3be32946c 100644 --- a/background/Background.vala +++ b/background/Background.vala @@ -6,6 +6,15 @@ */ public interface Gala.Background.Background : Object, Gdk.Paintable { + public struct ColorInformation { + double average_red; + double average_green; + double average_blue; + double mean_luminance; + double luminance_variance; + double mean_acutance; + } + public static Background get_for_color (Gdk.RGBA color) { return new SolidColor (color); } @@ -26,7 +35,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable { return new DimBackground (other); } - public abstract Utils.ColorInformation? get_color_information (int height); + public abstract ColorInformation? get_color_information (int height); private class SolidColor : Object, Gdk.Paintable, Background { public Gdk.RGBA color { get; construct; } @@ -35,7 +44,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable { Object (color: color); } - public Utils.ColorInformation? get_color_information (int height) { + public ColorInformation? get_color_information (int height) { return null; } @@ -60,7 +69,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable { Object (texture: texture); } - public Utils.ColorInformation? get_color_information (int height) { + public ColorInformation? get_color_information (int height) { var info = texture.get_color_information (height); if (info == null) { return null; @@ -108,7 +117,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable { Object (texture: texture); } - public Utils.ColorInformation? get_color_information (int height) { + public ColorInformation? get_color_information (int height) { return Utils.get_background_color_information (texture, height); } diff --git a/background/BackgroundManager.vala b/background/BackgroundManager.vala index 31c9f2d91..7f37a33dc 100644 --- a/background/BackgroundManager.vala +++ b/background/BackgroundManager.vala @@ -83,7 +83,7 @@ public class Gala.Background.BackgroundManager : Object { changed (); } - public Utils.ColorInformation? get_background_color_information (int height) throws DBusError, IOError { + public Background.ColorInformation? get_background_color_information (int height) throws DBusError, IOError { if (current_background == null) { return null; } diff --git a/background/Utils.vala b/background/Utils.vala index 161faebe6..543253e98 100644 --- a/background/Utils.vala +++ b/background/Utils.vala @@ -7,16 +7,7 @@ namespace Gala.Background.Utils { private const double SATURATION_WEIGHT = 1.5; private const double WEIGHT_THRESHOLD = 1.0; - public struct ColorInformation { - double average_red; - double average_green; - double average_blue; - double mean_luminance; - double luminance_variance; - double mean_acutance; - } - - public static ColorInformation? get_background_color_information (Gdk.Texture texture, int panel_height) { + public static Background.ColorInformation? get_background_color_information (Gdk.Texture texture, int panel_height) { int width = texture.width; int height = int.min (texture.height, panel_height);