[gnome-shell] windowPreview: Scale up by the same extra size for every window



commit 7d40930cd687823c3bf054b6824d5f47b9b7f607
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Feb 8 19:02:23 2021 +0100

    windowPreview: Scale up by the same extra size for every window
    
    Scaling differently sized WindowPreviews by a constant factor will
    result in smaller windows getting enlarged by a smaller amount of pixels
    than larger windows (1000*1.02=1020 but 100*1.02=102, one will grow by
    20 pixels and the other one by 2), this can look a bit weird because
    smaller windows don't scale up as much as larger windows.
    
    So introduce a constant extra size to use when scaling windows up, we
    set only the half size there because we want to ensure that the size
    added on both sides is not fractional and we remain aligned to the pixel
    grid.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1692>

 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 f4a65b620e..2527789485 100644
--- a/js/ui/windowPreview.js
+++ b/js/ui/windowPreview.js
@@ -13,7 +13,7 @@ var WINDOW_OVERLAY_IDLE_HIDE_TIMEOUT = 750;
 var WINDOW_OVERLAY_FADE_TIME = 200;
 
 var WINDOW_SCALE_TIME = 200;
-var WINDOW_ACTIVE_SCALE = 1.02;
+var WINDOW_ACTIVE_SIZE_INC = 5; // in each direction
 
 var DRAGGING_WINDOW_OPACITY = 100;
 
@@ -518,9 +518,14 @@ var WindowPreview = GObject.registerClass({
             });
         });
 
+        const { width } = this._windowContainer;
+        const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
+        const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * 2 * scaleFactor;
+        const scale = (width + activeExtraSize) / width;
+
         this._windowContainer.ease({
-            scale_x: WINDOW_ACTIVE_SCALE,
-            scale_y: WINDOW_ACTIVE_SCALE,
+            scale_x: scale,
+            scale_y: scale,
             duration: animate ? WINDOW_SCALE_TIME : 0,
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
         });


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