Skip to content

Commit

Permalink
Fix Wingpanel DBus interface implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter committed Sep 13, 2024
1 parent bd4132a commit b1ca60c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
28 changes: 12 additions & 16 deletions compositor/WingpanelManager/BackgroundUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions compositor/WingpanelManager/DBusWingpanelManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions compositor/WingpanelManager/WingpanelManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b1ca60c

Please sign in to comment.