diff --git a/compositor/WingpanelManager/BackgroundUtils.vala b/compositor/WingpanelManager/BackgroundUtils.vala index 6ec8a9d25..a98efc02d 100644 --- a/compositor/WingpanelManager/BackgroundUtils.vala +++ b/compositor/WingpanelManager/BackgroundUtils.vala @@ -32,12 +32,15 @@ namespace GreeterCompositor.BackgroundUtils { double mean_acutance; } - public async ColorInformation get_background_color_information (GreeterCompositor.WindowManager wm, - int reference_x, int reference_y, int reference_width, int reference_height) throws DBusError { - var bg_manager = (BackgroundManager) wm.background_group.get_child_at_index (wm.get_display ().get_primary_monitor ()); + public async ColorInformation get_background_color_information (GreeterCompositor.WindowManager wm, int panel_height) throws DBusError { + unowned var display = wm.get_display (); + var primary = display.get_primary_monitor (); + var geometry = display.get_monitor_geometry (primary); + + var bg_manager = (BackgroundManager) wm.background_group.get_child_at_index (primary); if (bg_manager == null) { - throw new DBusError.INVALID_ARGS ("Invalid monitor requested: %i".printf (wm.get_display ().get_primary_monitor ())); + throw new DBusError.INVALID_ARGS ("Couldn't get BackgroundManagerInterface on monitor %i".printf (primary)); } var effect = new DummyOffscreenEffect (); @@ -52,25 +55,18 @@ namespace GreeterCompositor.BackgroundUtils { // black border. The commit specifies that up to 1.75px around each side // could now be padding, so cut off 2px from left and top if necessary // (https://gitlab.gnome.org/GNOME/mutter/commit/8655bc5d8de6a969e0ca83eff8e450f62d28fbee) - int x_start = reference_x; - if (x_start < 2) { - x_start = 2; - } - - int y_start = reference_y; - if (y_start < 2) { - y_start = 2; - } + var x_start = 2; + var y_start = 2; // For the same reason as above, we need to not use the bottom and right // 2px of the texture. However, if the caller has specified an area of // interest that already misses these parts, use that instead, otherwise // chop 2px - int width = int.min (bg_actor_width - 2 - reference_x, reference_width); - int height = int.min (bg_actor_height - 2 - reference_y, reference_height); + int width = int.min (bg_actor_width - 2, geometry.width); + int height = int.min (bg_actor_height - 2, panel_height); if (x_start > bg_actor_width || y_start > bg_actor_height || width <= 0 || height <= 0) { - throw new DBusError.INVALID_ARGS ("Invalid rectangle specified: %i, %i, %i, %i".printf (x_start, y_start, width, height)); + throw new DBusError.INVALID_ARGS ("Got invalid rectangle: %i, %i, %i, %i".printf (x_start, y_start, width, height)); } double mean_acutance = 0, variance = 0, mean = 0, r_total = 0, g_total = 0, b_total = 0; diff --git a/compositor/WingpanelManager/DBusWingpanelManager.vala b/compositor/WingpanelManager/DBusWingpanelManager.vala index 9a41ebcfd..951bfe1a4 100644 --- a/compositor/WingpanelManager/DBusWingpanelManager.vala +++ b/compositor/WingpanelManager/DBusWingpanelManager.vala @@ -27,13 +27,13 @@ public class GreeterCompositor.DBusWingpanelManager : GLib.Object { } }, () => {}, - () => warning ("Could not acquire name\n") + () => warning ("Could not acquire name") ); } public signal void state_changed (BackgroundState state, uint animation_duration); - public void initialize (int monitor, int panel_height) throws GLib.Error { + public void initialize (int panel_height) throws GLib.Error { background_manager = new WingpanelManager (wm, panel_height); background_manager.state_changed.connect ((state, animation_duration) => { state_changed (state, animation_duration); diff --git a/compositor/WingpanelManager/WingpanelManager.vala b/compositor/WingpanelManager/WingpanelManager.vala index f02478005..0bac59084 100644 --- a/compositor/WingpanelManager/WingpanelManager.vala +++ b/compositor/WingpanelManager/WingpanelManager.vala @@ -116,10 +116,7 @@ public class GreeterCompositor.WingpanelManager : Object { public async void update_bk_color_info () { SourceFunc callback = update_bk_color_info.callback; - var monitor = wm.get_display ().get_primary_monitor (); - var monitor_geometry = wm.get_display ().get_monitor_geometry (monitor); - - BackgroundUtils.get_background_color_information.begin (wm, 0, 0, monitor_geometry.width, panel_height, (obj, res) => { + BackgroundUtils.get_background_color_information.begin (wm, panel_height, (obj, res) => { try { bk_color_info = BackgroundUtils.get_background_color_information.end (res); } catch (Error e) {