[gnome-shell] workspace: Clip background



commit 9062d5dc78a4bebfb257e4e167663c4ce2680393
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jun 26 22:41:22 2020 +0200

    workspace: Clip background
    
    So that windows don't overflow the workspace background.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1599>

 js/ui/workspace.js | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index a87283b33a..4280512169 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -854,14 +854,20 @@ class WorkspaceBackground extends St.Widget {
         });
 
         this._monitorIndex = monitorIndex;
+        this._workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+
+        this._bin = new Clutter.Actor({
+            layout_manager: new Clutter.BinLayout(),
+            clip_to_allocation: true,
+        });
 
         this._backgroundGroup = new Meta.BackgroundGroup({
+            layout_manager: new Clutter.BinLayout(),
             x_expand: true,
             y_expand: true,
-            reactive: false,
-            layout_manager: new Clutter.BinLayout(),
         });
-        this.add_child(this._backgroundGroup);
+        this._bin.add_child(this._backgroundGroup);
+        this.add_child(this._bin);
 
         this._bgManager = new Background.BackgroundManager({
             container: this._backgroundGroup,
@@ -873,6 +879,27 @@ class WorkspaceBackground extends St.Widget {
         this.connect('destroy', this._onDestroy.bind(this));
     }
 
+    vfunc_allocate(box) {
+        this.set_allocation(box);
+
+        const themeNode = this.get_theme_node();
+        const contentBox = themeNode.get_content_box(box);
+
+        this._bin.allocate(contentBox);
+
+        const [contentWidth, contentHeight] = contentBox.get_size();
+        const monitor = Main.layoutManager.monitors[this._monitorIndex];
+        const xOff = (contentWidth / this._workarea.width) *
+            (this._workarea.x - monitor.x);
+        const yOff = (contentHeight / this._workarea.height) *
+            (this._workarea.y - monitor.y);
+
+        contentBox.x1 -= xOff;
+        contentBox.y1 -= yOff;
+        contentBox.set_size(xOff + contentWidth, yOff + contentHeight);
+        this._backgroundGroup.allocate(contentBox);
+    }
+
     _onDestroy() {
         if (this._bgManager) {
             this._bgManager.destroy();


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