[gnome-shell/wip/exalm/gestures2: 5/9] workspaceAnimation: Add a background



commit f77c9d5fc37134cae4409f918464b4064638a391
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Jul 16 15:40:13 2020 +0500

    workspaceAnimation: Add a background
    
    In future we will need to use window clones to better support multiple
    monitors. To avoid having to hide every window, show wallpapers behind
    the workspace transition: one per monitor.
    
    Put the wallpaper into a separate class right away, later it will be
    useful to make the animation per-monitor.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1326

 js/ui/workspaceAnimation.js | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js
index 0a0c498794..00e8617160 100644
--- a/js/ui/workspaceAnimation.js
+++ b/js/ui/workspaceAnimation.js
@@ -3,6 +3,8 @@
 
 const { Clutter, GObject, Meta, Shell } = imports.gi;
 
+const Background = imports.ui.background;
+const Layout = imports.ui.layout;
 const Main = imports.ui.main;
 const SwipeTracker = imports.ui.swipeTracker;
 
@@ -92,6 +94,34 @@ class WorkspaceGroup extends Clutter.Actor {
     }
 });
 
+const MonitorGroup = GObject.registerClass(
+class MonitorGroup extends Clutter.Actor {
+    _init(monitor) {
+        super._init();
+
+        const constraint = new Layout.MonitorConstraint({ index: monitor.index });
+        this.add_constraint(constraint);
+
+        const background = new Meta.BackgroundGroup({
+            x: -monitor.x,
+            y: -monitor.y,
+        });
+
+        this.add_child(background);
+
+        this._bgManager = new Background.BackgroundManager({
+            container: background,
+            monitorIndex: monitor.index,
+        });
+
+        this.connect('destroy', this._onDestroy.bind(this));
+    }
+
+    _onDestroy() {
+        this._bgManager.destroy();
+    }
+});
+
 var WorkspaceAnimationController = class {
     constructor() {
         this._movingWindow = null;
@@ -167,8 +197,16 @@ var WorkspaceAnimationController = class {
 
         switchData.container = new Clutter.Actor();
         switchData.container.add_child(switchData.curGroup);
+        switchData.backgrounds = [];
+
+        for (const monitor of Main.layoutManager.monitors) {
+            const background = new MonitorGroup(monitor);
+            switchData.backgrounds.push(background);
+
+            Main.uiGroup.insert_child_above(background, global.window_group);
+        }
 
-        Main.uiGroup.insert_child_above(switchData.container, global.window_group);
+        Main.uiGroup.insert_child_above(switchData.container, switchData.backgrounds[0]);
         Main.uiGroup.insert_child_above(switchData.movingWindowBin, switchData.container);
 
         for (const dir of Object.values(Meta.MotionDirection)) {
@@ -226,6 +264,7 @@ var WorkspaceAnimationController = class {
             switchData.movingWindow = null;
         }
 
+        switchData.backgrounds.forEach(bg => bg.destroy());
         switchData.container.destroy();
         switchData.movingWindowBin.destroy();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]