[gnome-shell] WindowOverlay: fix title sizing



commit 944762ac830cb5401d5447da55ed667212f7ee71
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Dec 17 00:42:40 2012 +0100

    WindowOverlay: fix title sizing
    
    After the first time the title was placed, we were setting its width,
    thus forcing get_preferred_width() to return that as the minimum and
    natural width.
    To workaround that, explicitly reset the width to -1, -1, causing
    StLabel->get_preferred_width() to be called, which would give us a meaningful
    value for minimum and natural width.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688234

 js/ui/workspace.js |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index acbcd37..25877b2 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -557,8 +557,16 @@ const WindowOverlay = new Lang.Class({
         else
             button.set_position(Math.floor(buttonX), Math.floor(buttonY));
 
+        // Clutter.Actor.get_preferred_width() will return the fixed width if one
+        // is set, so we need to reset the width by calling set_width(-1), to forward
+        // the call down to StLabel.
+        // We also need to save and restore the current width, otherwise the animation
+        // starts from the wrong point.
+        let prevTitleWidth = title.width;
+        title.set_width(-1);
         let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1);
         let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth));
+        title.width = prevTitleWidth;
 
         let titleX = cloneX + (cloneWidth - titleWidth) / 2;
         let titleY = cloneY + cloneHeight + title._spacing;



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