From 944762ac830cb5401d5447da55ed667212f7ee71 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 17 Dec 2012 00:42:40 +0100 Subject: [PATCH] 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 file changed, 8 insertions(+) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index acbcd377a..25877b20b 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;