[gnome-shell] windowPreview: Ensure style as soon as preview is realized



commit c26860dcb7da9fd51a5dced984c34024664f770e
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Jul 6 15:44:25 2020 +0200

    windowPreview: Ensure style as soon as preview is realized
    
    For the windowPreview we need to ensure the style information of the
    border and title is up-to-date when chromeWidths() or chromeHeights() is
    called. Since the introduction of the WorkspaceLayout those functions
    may be called during an allocation cycle, which means we should avoid
    calling queuing relayouts inside them. Calling StWidgets ensure_style()
    method will queue a relayout though in case the newly generated theme
    node has a different geometry.
    
    So avoid queueing a relayout during allocation cycles (and the warning
    Clutter logs because of that) by ensuring the style of the border and
    title earlier, as soon as the WindowPreview is attached to a stage.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1305

 js/ui/windowPreview.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js
index 69e3ee5748..caa0732648 100644
--- a/js/ui/windowPreview.js
+++ b/js/ui/windowPreview.js
@@ -347,6 +347,14 @@ var WindowPreview = GObject.registerClass({
         this.add_child(this._border);
         this.add_child(this._title);
         this.add_child(this._closeButton);
+
+        this.connect('notify::realized', () => {
+            if (!this.realized)
+                return;
+
+            this._border.ensure_style();
+            this._title.ensure_style();
+        });
     }
 
     vfunc_get_preferred_width(forHeight) {
@@ -401,8 +409,6 @@ var WindowPreview = GObject.registerClass({
     }
 
     chromeHeights() {
-        this._border.ensure_style();
-        this._title.ensure_style();
         const [, closeButtonHeight] = this._closeButton.get_preferred_height(-1);
         const [, titleHeight] = this._title.get_preferred_height(-1);
 
@@ -415,7 +421,6 @@ var WindowPreview = GObject.registerClass({
     }
 
     chromeWidths() {
-        this._border.ensure_style();
         const [, closeButtonWidth] = this._closeButton.get_preferred_width(-1);
 
         const leftOversize = this._closeButtonSide === St.Side.LEFT


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