[gnome-shell] windowPreview: Ensure scaling is limited to defined size increase



commit ef5b92c5967235299b61116d2ebf4ea83e895ebd
Author: Sebastian Keller <skeller gnome org>
Date:   Sun Feb 21 18:38:05 2021 +0100

    windowPreview: Ensure scaling is limited to defined size increase
    
    The preview was getting scaled up by a factor based on what is needed to
    increase the width by activeExtraSize pixels. With windows that are
    wider than than they are tall, this means that the size of the window
    will not increase any more than activeExtraSize in any direction, but
    for windows that are taller than they are wide, the vertical scaling
    can exceed this. This would break some of the assumptions in the
    reported size for the preview chrome and could for very narrow windows
    result in a rather large scale.
    
    To fix this, calculate the scaling factor based on whatever is larger,
    the height or the width.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1707>

 js/ui/windowPreview.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js
index 1659d00775..a27d0586f4 100644
--- a/js/ui/windowPreview.js
+++ b/js/ui/windowPreview.js
@@ -528,10 +528,11 @@ var WindowPreview = GObject.registerClass({
             });
         });
 
-        const { width } = this._windowContainer;
+        const [width, height] = this._windowContainer.get_size();
         const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
         const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * 2 * scaleFactor;
-        const scale = (width + activeExtraSize) / width;
+        const origSize = Math.max(width, height);
+        const scale = (origSize + activeExtraSize) / origSize;
 
         this._windowContainer.ease({
             scale_x: scale,


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