Skip to content

Commit

Permalink
Background: respect animations key (#1779)
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 Oct 26, 2023
1 parent 5a917de commit 86293d4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/Background/BackgroundContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace Gala {
public signal void changed ();
public signal void show_background_menu (int x, int y);

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }

public BackgroundContainer (Meta.Display display) {
Object (display: display);
public BackgroundContainer (WindowManager wm) {
Object (wm: wm);
}

construct {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (update);

reactive = true;
Expand All @@ -43,7 +43,7 @@ namespace Gala {
}

~BackgroundContainer () {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.disconnect (update);
}

Expand All @@ -54,8 +54,8 @@ namespace Gala {

destroy_all_children ();

for (var i = 0; i < display.get_n_monitors (); i++) {
var background = new BackgroundManager (display, i);
for (var i = 0; i < wm.get_display ().get_n_monitors (); i++) {
var background = new BackgroundManager (wm, i);

add_child (background);

Expand Down
12 changes: 7 additions & 5 deletions src/Background/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ namespace Gala {

public signal void changed ();

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }
public int monitor_index { get; construct; }
public bool control_position { get; construct; }

private BackgroundSource background_source;
private Meta.BackgroundActor background_actor;
private Meta.BackgroundActor? new_background_actor = null;

public BackgroundManager (Meta.Display display, int monitor_index, bool control_position = true) {
Object (display: display, monitor_index: monitor_index, control_position: control_position);
public BackgroundManager (WindowManager wm, int monitor_index, bool control_position = true) {
Object (wm: wm, monitor_index: monitor_index, control_position: control_position);
}

construct {
background_source = BackgroundCache.get_default ().get_background_source (display);
background_source = BackgroundCache.get_default ().get_background_source (wm.get_display ());
background_actor = create_background_actor ();

destroy.connect (on_destroy);
Expand Down Expand Up @@ -66,7 +66,7 @@ namespace Gala {
if (old_background_actor == null)
return;

if (animate) {
if (animate && wm.enable_animations) {
var transition = new Clutter.PropertyTransition ("opacity");
transition.set_from_value (255);
transition.set_to_value (0);
Expand Down Expand Up @@ -125,6 +125,8 @@ namespace Gala {
}

private Meta.BackgroundActor create_background_actor () {
unowned var display = wm.get_display ();

var background = background_source.get_background (monitor_index);
var background_actor = new Meta.BackgroundActor (display, monitor_index);

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MonitorClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Gala {
construct {
reactive = true;

background = new BackgroundManager (display, monitor, false);
background = new BackgroundManager (wm, monitor, false);

var scale = display.get_monitor_scale (monitor);

Expand Down
14 changes: 9 additions & 5 deletions src/Widgets/WorkspaceClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ namespace Gala {
private int last_width;
private int last_height;

public FramedBackground (Meta.Display display) {
Object (display: display, monitor_index: display.get_primary_monitor (), control_position: false);
public FramedBackground (WindowManager wm) {
Object (
wm: wm,
monitor_index: wm.get_display ().get_primary_monitor (),
control_position: false
);
}

construct {
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
var primary = display.get_primary_monitor ();
var monitor_geom = display.get_monitor_geometry (primary);
var primary = wm.get_display ().get_primary_monitor ();
var monitor_geom = wm.get_display ().get_monitor_geometry (primary);

var effect = new ShadowEffect (40) {
css_class = "workspace"
Expand Down Expand Up @@ -175,7 +179,7 @@ namespace Gala {
background_click_action.clicked.connect (() => {
selected (true);
});
background = new FramedBackground (display);
background = new FramedBackground (wm);
background.add_action (background_click_action);

window_container = new WindowCloneContainer (wm, gesture_tracker, scale_factor);
Expand Down
2 changes: 1 addition & 1 deletion src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace Gala {
stage.remove_child (window_group);
ui_group.add_child (window_group);

background_group = new BackgroundContainer (display);
background_group = new BackgroundContainer (this);
((BackgroundContainer)background_group).show_background_menu.connect (on_show_background_menu);
window_group.add_child (background_group);
window_group.set_child_below_sibling (background_group, null);
Expand Down

0 comments on commit 86293d4

Please sign in to comment.