Skip to content

Commit c8e0288

Browse files
authored
backgrounds: Improve wayland session support. (#13614)
- Muffin can provide background actors for both session types. Wayland's will depend on wlr-layer-shell background layer surfaces. - Throwaway background actors are now per-monitor (with a convenience wrapper for a combined one in Main.js. - Meta.create_background_for_monitor() for throwaway actos works regardless of session type, use this and remove all wayland checks. - cinnamon-global: Add global.get_background_actors() to access stage wallpaper actors, mark 'background-actor' as deprecated. It returns NULL. Main.createFullScreenBackground() can be used as a replacement for a single actor spanning the stage. - Mark Meta.BackgroundActor.new_for_screen() as deprecated, it will only return the first monitor's background in X11 mode now, and an empty ClutterActor otherwise (like before).
1 parent e671fdf commit c8e0288

10 files changed

Lines changed: 69 additions & 67 deletions

File tree

js/ui/appSwitcher/appSwitcher3D.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const PREVIEW_SCALE = 0.5;
2121
const TITLE_POSITION = 7/8; // percent position
2222
var ANIMATION_TIME = 250; // ms
2323
const SWITCH_TIME_DELAY = 100; // milliseconds
24-
const DIM_FACTOR = 0.4; // percent
24+
const DIM_OPACITY = 102;
2525

2626
function AppSwitcher3D() {
2727
this._init.apply(this, arguments);
@@ -37,11 +37,7 @@ AppSwitcher3D.prototype = {
3737
this._icon = null;
3838
this._lastTime = 0;
3939

40-
if (!Meta.is_wayland_compositor()) {
41-
this._background = Meta.X11BackgroundActor.new_for_display(global.display);
42-
} else {
43-
this._background = new Clutter.Actor();
44-
}
40+
this._background = Main.createFullScreenBackground();
4541

4642
this._background.hide();
4743
global.overlay_group.add_actor(this._background);
@@ -75,7 +71,7 @@ AppSwitcher3D.prototype = {
7571
Main.panelManager.panels.forEach(function(panel) { panel.actor.set_reactive(false); });
7672

7773
this._background.ease({
78-
dim_factor: DIM_FACTOR,
74+
opacity: DIM_OPACITY,
7975
duration: ANIMATION_TIME,
8076
mode: Clutter.AnimationMode.EASE_OUT_QUAD
8177
});
@@ -140,7 +136,7 @@ AppSwitcher3D.prototype = {
140136
// background
141137
this._background.remove_all_transitions();
142138
this._background.ease({
143-
dim_factor: 1.0,
139+
opacity: 255,
144140
duration: ANIMATION_TIME,
145141
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
146142
onComplete: () => this._destroyActors()

js/ui/backgroundManager.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,14 @@ var BackgroundManager = class {
3434
}
3535

3636
showBackground() {
37-
if (Meta.is_wayland_compositor()) {
38-
global.bottom_window_group.show();
39-
}
40-
else {
41-
global.background_actor.show();
37+
for (let actor of global.get_background_actors()) {
38+
actor.show();
4239
}
4340
}
4441

4542
hideBackground() {
46-
if (Meta.is_wayland_compositor()) {
47-
global.bottom_window_group.hide();
48-
}
49-
else {
50-
global.background_actor.hide();
43+
for (let actor of global.get_background_actors()) {
44+
actor.hide();
5145
}
5246
}
5347

js/ui/expo.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ Expo.prototype = {
3838
// one. Instances of this class share a single CoglTexture behind the
3939
// scenes which allows us to show the background with different
4040
// rendering options without duplicating the texture data.
41-
if (!Meta.is_wayland_compositor()) {
42-
this._background = Meta.X11BackgroundActor.new_for_display(global.display);
43-
} else {
44-
this._background = new Clutter.Actor();
45-
}
46-
41+
this._background = Main.createFullScreenBackground();
4742
this._background.hide();
4843
global.overlay_group.add_actor(this._background);
4944

@@ -349,13 +344,6 @@ Expo.prototype = {
349344
this._gradient.show();
350345
Main.panelManager.disablePanels();
351346

352-
this._background.dim_factor = 1;
353-
this._background.ease({
354-
dim_factor: 0.4,
355-
duration: Main.animations_enabled ? ANIMATION_TIME : 0,
356-
mode: Clutter.AnimationMode.EASE_OUT_QUAD
357-
});
358-
359347
activeWorkspace.setOverviewMode(true);
360348

361349
this._coverPane.raise_top();

js/ui/expoThumbnail.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,8 @@ ExpoWorkspaceThumbnail.prototype = {
390390
this.background = new Clutter.Group();
391391
this.contents.add_actor(this.background);
392392

393-
if (!Meta.is_wayland_compositor()) {
394-
let desktopBackground = Meta.X11BackgroundActor.new_for_display(global.display);
395-
this.background.add_actor(desktopBackground);
396-
}
393+
let desktopBackground = Main.createFullScreenBackground();
394+
this.background.add_actor(desktopBackground);
397395

398396
let backgroundShade = new St.Bin({style_class: 'workspace-overview-background-shade'});
399397
this.background.add_actor(backgroundShade);

js/ui/main.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,32 @@ function getPanels() {
672672
return panelManager.getPanels();
673673
}
674674

675+
/**
676+
* createFullScreenBackground:
677+
*
678+
* Creates a full-stage background actor containing one background per monitor.
679+
* On X11, each child is the root pixmap actor positioned at the monitor's
680+
* location. On Wayland, each child is a clone of the layer-shell background
681+
* surface for that monitor.
682+
*
683+
* Returns: a ClutterActor covering all monitors
684+
*/
685+
function createFullScreenBackground() {
686+
let container = new imports.gi.Clutter.Actor();
687+
688+
for (let i = 0; i < layoutManager.monitors.length; i++) {
689+
let monitor = layoutManager.monitors[i];
690+
let bg = Meta.create_background_for_monitor(global.display, i);
691+
if (bg) {
692+
bg.set_position(monitor.x, monitor.y);
693+
bg.set_size(monitor.width, monitor.height);
694+
container.add_child(bg);
695+
}
696+
}
697+
698+
return container;
699+
}
700+
675701
let _workspaces = [];
676702
let _checkWorkspacesId = 0;
677703

js/ui/overrides.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ function overrideClutter() {
127127
}
128128

129129
function overrideMeta() {
130-
Meta.BackgroundActor.new_for_screen = function(screen) {
131-
if (!Meta.is_wayland_compositor()) {
132-
return Meta.X11BackgroundActor.new_for_display(global.display);
133-
} else {
134-
return new Clutter.Actor();
130+
Meta.BackgroundActor = {
131+
new_for_screen: function(_screen) {
132+
logError("Meta.BackgroundActor.new_for_screen() is deprecated, use Meta.create_background_for_monitor() or Main.createFullScreenBackground().");
133+
return Meta.X11BackgroundActor.new_for_display(global.display) ||
134+
new Clutter.Actor();
135135
}
136-
}
136+
};
137137

138138
Meta.disable_unredirect_for_screen = function(screen) {
139139
Meta.disable_unredirect_for_display(global.display);

js/ui/overview.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,10 @@ Overview.prototype = {
247247
// one. Instances of this class share a single CoglTexture behind the
248248
// scenes which allows us to show the background with different
249249
// rendering options without duplicating the texture data.
250-
this._background = new Clutter.Actor();
250+
this._background = Main.createFullScreenBackground();
251251
this._background.set_position(0, 0);
252252
this._group.add_actor(this._background);
253253

254-
let desktopBackground;
255-
if (!Meta.is_wayland_compositor()) {
256-
desktopBackground = Meta.X11BackgroundActor.new_for_display(global.display);
257-
} else {
258-
desktopBackground = new Clutter.Actor();
259-
}
260-
261-
this._background.add_actor(desktopBackground);
262-
263254
let backgroundShade = new St.Bin({style_class: 'workspace-overview-background-shade'});
264255
backgroundShade.set_size(global.screen_width, global.screen_height);
265256
this._background.add_actor(backgroundShade);

js/ui/screensaver/screenShield.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,23 +1164,13 @@ var ScreenShield = GObject.registerClass({
11641164
_createBackgrounds() {
11651165
this._destroyBackgrounds();
11661166

1167-
if (Meta.is_wayland_compositor()) {
1168-
// TODO: Waiting on:
1169-
// muffin: https://github.com/linuxmint/muffin/pull/784
1170-
// cinnamon-settings-daemon: https://github.com/linuxmint/cinnamon-settings-daemon/pull/437
1171-
//
1172-
// Once those are merged we can access the layer-shell surfaces of csd-background and avoid
1173-
// having to load them in Cinnamon.
1174-
//
1175-
// For now, there is only a black background for the screensaver.
1176-
return;
1177-
}
1178-
11791167
let nMonitors = Main.layoutManager.monitors.length;
11801168

11811169
for (let i = 0; i < nMonitors; i++) {
11821170
let monitor = Main.layoutManager.monitors[i];
1183-
let background = Meta.X11BackgroundActor.new_for_display(global.display);
1171+
let background = Meta.create_background_for_monitor(global.display, i);
1172+
if (!background)
1173+
continue;
11841174

11851175
background.reactive = false;
11861176

src/cinnamon-global.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <meta/meta-x11-display.h>
1010
#include <meta/compositor-muffin.h>
1111
#include <meta/meta-cursor-tracker.h>
12-
#include <meta/meta-background-actor.h>
1312
#include <meta/meta-settings.h>
1413
#include <meta/meta-backend.h>
1514
#include <meta/util.h>
@@ -145,6 +144,8 @@ cinnamon_global_get_property(GObject *object,
145144
g_value_set_object (value, meta_get_top_window_group_for_display (global->meta_display));
146145
break;
147146
case PROP_BACKGROUND_ACTOR:
147+
g_warning_once ("global.background_actor is deprecated and X11-only. "
148+
"Use global.get_background_actors() instead.");
148149
g_value_set_object (value, meta_get_x11_background_actor_for_display (global->meta_display));
149150
break;
150151
case PROP_DESKLET_CONTAINER:
@@ -392,9 +393,9 @@ cinnamon_global_class_init (CinnamonGlobalClass *klass)
392393
PROP_BACKGROUND_ACTOR,
393394
g_param_spec_object ("background-actor",
394395
"Background Actor",
395-
"Actor drawing root window background",
396+
"Actor drawing root window background (X11 only, deprecated)",
396397
CLUTTER_TYPE_ACTOR,
397-
G_PARAM_READABLE));
398+
G_PARAM_READABLE | G_PARAM_DEPRECATED));
398399
g_object_class_install_property (gobject_class,
399400
PROP_DESKLET_CONTAINER,
400401
g_param_spec_object ("desklet-container",
@@ -760,6 +761,23 @@ cinnamon_global_get_window_actors (CinnamonGlobal *global)
760761
return meta_get_window_actors (global->meta_display);
761762
}
762763

764+
/**
765+
* cinnamon_global_get_background_actors:
766+
*
767+
* Gets the list of per-monitor background actors created by
768+
* meta_create_background_for_monitor(). These are the live actors in the
769+
* scene graph and can have effects applied to them directly.
770+
*
771+
* Return value: (element-type Clutter.Actor) (transfer none): the list of background actors
772+
*/
773+
GList *
774+
cinnamon_global_get_background_actors (CinnamonGlobal *global)
775+
{
776+
g_return_val_if_fail (CINNAMON_IS_GLOBAL (global), NULL);
777+
778+
return meta_get_background_actors_for_display (global->meta_display);
779+
}
780+
763781
static void
764782
global_stage_notify_width (GObject *gobject,
765783
GParamSpec *pspec,

src/cinnamon-global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ClutterStage *cinnamon_global_get_stage (CinnamonGlobal *global
3232
CinnamonScreen *cinnamon_global_get_screen (CinnamonGlobal *global);
3333
MetaDisplay *cinnamon_global_get_display (CinnamonGlobal *global);
3434
GList *cinnamon_global_get_window_actors (CinnamonGlobal *global);
35+
GList *cinnamon_global_get_background_actors (CinnamonGlobal *global);
3536
GSettings *cinnamon_global_get_settings (CinnamonGlobal *global);
3637
guint32 cinnamon_global_get_current_time (CinnamonGlobal *global);
3738
pid_t cinnamon_global_get_pid (CinnamonGlobal *global);

0 commit comments

Comments
 (0)