Skip to content

Commit

Permalink
Use BackgroundManager to get wallpaper (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Feb 20, 2024
1 parent 52aa9a7 commit 0c35f4d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions wingpanel-interface/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ namespace WingpanelInterface.Utils {

public async ColorInformation get_background_color_information (Gala.WindowManager wm, int monitor,
int reference_x, int reference_y, int reference_width, int reference_height) throws DBusError {
var background = wm.background_group.get_child_at_index (monitor);
var bg_manager = (Gala.BackgroundManagerInterface) wm.background_group.get_child_at_index (monitor);

if (background == null) {
if (bg_manager == null) {
throw new DBusError.INVALID_ARGS ("Invalid monitor requested: %i".printf (monitor));
}

var effect = new DummyOffscreenEffect ();
background.add_effect (effect);
unowned var newest_background_actor = bg_manager.newest_background_actor;
newest_background_actor.add_effect (effect);

var bg_actor_width = (int)background.width;
var bg_actor_height = (int)background.height;
var bg_actor_width = (int) newest_background_actor.width;
var bg_actor_height = (int) newest_background_actor.height;

// A commit in mutter added some padding to offscreen textures, so we
// need to avoid looking at the edges of the texture as it often has a
Expand Down Expand Up @@ -91,7 +92,7 @@ namespace WingpanelInterface.Utils {

paint_signal_handler = effect.done_painting.connect (() => {
SignalHandler.disconnect (effect, paint_signal_handler);
background.remove_effect (effect);
newest_background_actor.remove_effect (effect);

var texture = (Cogl.Texture)effect.get_texture ();
var texture_width = texture.get_width ();
Expand Down Expand Up @@ -211,7 +212,7 @@ namespace WingpanelInterface.Utils {
get_background_color_information.callback ();
});

background.queue_redraw ();
newest_background_actor.queue_redraw ();

yield;

Expand Down

0 comments on commit 0c35f4d

Please sign in to comment.