From bc158d55ee0b073161775be7ab1e54c97f441b73 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Jan 30 2021 03:37:04 +0000 Subject: [PATCH 1/3] Adjust to overview background moving into workspace Workspaces are recreated every time when entering the overview, so we don't have to refresh its background on enable/disable. --- diff --git a/extension.js b/extension.js index 6381857..a3b8d0e 100644 --- a/extension.js +++ b/extension.js @@ -226,7 +226,6 @@ class Extension { _reloadBackgrounds() { Main.layoutManager._updateBackgrounds(); - Main.overview._updateBackgrounds(); } enable() { From 335bc6abb3aa4b7808bc71f9975c4aca9e97df91 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Jan 30 2021 03:37:04 +0000 Subject: [PATCH 2/3] Don't add monitor constraint In GNOME 40, we can no longer assume that background actors are monitor sized. Adjust to that by filling the parent instead of adding a monitor constraint. --- diff --git a/extension.js b/extension.js index a3b8d0e..f5f56a4 100644 --- a/extension.js +++ b/extension.js @@ -19,7 +19,6 @@ const { Clutter, Gio, GObject, St } = imports.gi; const Background = imports.ui.background; const ExtensionUtils = imports.misc.extensionUtils; -const Layout = imports.ui.layout; const Main = imports.ui.main; var IconContainer = GObject.registerClass( @@ -78,8 +77,11 @@ class BackgroundLogo extends St.Widget { super._init({ layout_manager: new Clutter.BinLayout(), + x_expand: true, + y_expand: true, opacity: 0, }); + this._backgroundActor.layout_manager = new Clutter.BinLayout(); this._backgroundActor.add_child(this); this.connect('destroy', this._onDestroy.bind(this)); @@ -87,12 +89,6 @@ class BackgroundLogo extends St.Widget { this._backgroundActor.content.connect('notify::brightness', this._updateOpacity.bind(this)); - let constraint = new Layout.MonitorConstraint({ - index: this._monitorIndex, - work_area: true, - }); - this.add_constraint(constraint); - this._bin = new IconContainer({ x_expand: true, y_expand: true }); this.add_actor(this._bin); this._bin.connect('resource-scale-changed', @@ -210,6 +206,7 @@ class BackgroundLogo extends St.Widget { } _onDestroy() { + this._backgroundActor.layout_manager = null; this._settings.run_dispose(); this._settings = null; From 574ed73731399b0d48e678d99a36215c8e70fd5d Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Jan 30 2021 03:37:13 +0000 Subject: [PATCH 3/3] Scale size and border with background actor As background actors are no longer tied to the monitor size, we have to adjust the logo size and border with the actor's allocation. Otherwise the logo's actual size would remain constant on actor size changes, rather than its relative size. --- diff --git a/extension.js b/extension.js index f5f56a4..d1bf35b 100644 --- a/extension.js +++ b/extension.js @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -const { Clutter, Gio, GObject, St } = imports.gi; +const { Clutter, Gio, GLib, GObject, Meta, St } = imports.gi; const Background = imports.ui.background; const ExtensionUtils = imports.misc.extensionUtils; @@ -128,6 +128,14 @@ class BackgroundLogo extends St.Widget { return width * size / 100; } + _getActorScale() { + if (!this.has_allocation()) + return 1; + + let { width } = this._getWorkArea(); + return this.allocation.get_width() / width; + } + _updateLogoTexture() { if (this._icon) this._icon.destroy(); @@ -152,7 +160,7 @@ class BackgroundLogo extends St.Widget { let size = this._settings.get_double('logo-size'); let width = this._getWidthForRelativeSize(size); - let scale = width / this._icon.width; + let scale = this._getActorScale() * width / this._icon.width; this._bin.set_scale(scale, scale); } @@ -181,8 +189,14 @@ class BackgroundLogo extends St.Widget { } _updateBorder() { - let border = this._settings.get_uint('logo-border'); - this.style = 'padding: %dpx;'.format(border); + const border = + this._getActorScale() * this._settings.get_uint('logo-border'); + this._bin.set({ + margin_top: border, + margin_bottom: border, + margin_left: border, + margin_right: border, + }); } _updateVisibility() { @@ -205,7 +219,26 @@ class BackgroundLogo extends St.Widget { }); } + vfunc_allocate(box) { + super.vfunc_allocate(box); + + if (this._laterId) + return; + + this._laterId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { + this._updateScale(); + this._updateBorder(); + + this._laterId = 0; + return GLib.SOURCE_REMOVE; + }); + } + _onDestroy() { + if (this._laterId) + Meta.later_remove(this._laterId); + this._laterId = 0; + this._backgroundActor.layout_manager = null; this._settings.run_dispose(); this._settings = null;