[gnome-shell] workspace: Update background on workarea changes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] workspace: Update background on workarea changes
- Date: Sun, 21 Feb 2021 15:58:55 +0000 (UTC)
commit b05280a2cd9275270bbeb9b697ff2c41923c8161
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Feb 15 17:35:24 2021 -0300
workspace: Update background on workarea changes
The WorkspaceBackground class has specific code to clip the background
to the workarea. However, it doesn't monitor for workarea changes, which
means it cannot react after being created.
Connect to 'workareas-changed', and update the workarea, the radius bounds,
and relayout when workareas change.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1691>
js/ui/workspace.js | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 403c5dded0..fd5d57f4c5 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -905,9 +905,29 @@ class WorkspaceBackground extends St.Widget {
useContentSize: false,
});
+ this._workareasChangedId =
+ global.display.connect('workareas-changed', () => {
+ this._workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+ this._updateRoundedClipBounds();
+ this.queue_relayout();
+ });
+ this._updateRoundedClipBounds();
+
this.connect('destroy', this._onDestroy.bind(this));
}
+ _updateRoundedClipBounds() {
+ const monitor = Main.layoutManager.monitors[this._monitorIndex];
+
+ const rect = new Graphene.Rect();
+ rect.origin.x = this._workarea.x - monitor.x;
+ rect.origin.y = this._workarea.y - monitor.y;
+ rect.size.width = this._workarea.width;
+ rect.size.height = this._workarea.height;
+
+ this._bgManager.backgroundActor.content.set_rounded_clip_bounds(rect);
+ }
+
vfunc_allocate(box) {
this.set_allocation(box);
@@ -923,14 +943,6 @@ class WorkspaceBackground extends St.Widget {
const yOff = (contentHeight / this._workarea.height) *
(this._workarea.y - monitor.y);
- const rect = new Graphene.Rect();
- rect.origin.x = this._workarea.x - monitor.x;
- rect.origin.y = this._workarea.y - monitor.y;
- rect.size.width = this._workarea.width;
- rect.size.height = this._workarea.height;
-
- this._bgManager.backgroundActor.content.set_rounded_clip_bounds(rect);
-
contentBox.x1 -= xOff;
contentBox.y1 -= yOff;
contentBox.set_size(xOff + contentWidth, yOff + contentHeight);
@@ -942,6 +954,11 @@ class WorkspaceBackground extends St.Widget {
this._bgManager.destroy();
this._bgManager = null;
}
+
+ if (this._workareasChangedId) {
+ global.display.disconnect(this._workareasChangedId);
+ delete this._workareasChangedId;
+ }
}
set cornerRadius(radius) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]