[gnome-shell] workspace: Scale down wallpaper by a fixed number of pixels



commit 99378b6dae61bb54ad9aae121fce0ee2f7cd62f6
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Feb 22 12:50:29 2021 +0100

    workspace: Scale down wallpaper by a fixed number of pixels
    
    To ensure the workspace thumbnails are vertically closer to the window
    picker than to the search, scale down the wallpapers by a fixed number
    of pixels. Using 24 px for this means we'll take of 12 px at the top and
    12 px at the bottom of the wallpaper, that's a better strategy than
    always scaling it by a fixed factor since it doesn't change with the
    monitor size.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1702>

 js/ui/workspace.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index ee33f302ab..fbbbef2b3b 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -24,7 +24,7 @@ var LAYOUT_SCALE_WEIGHT = 1;
 var LAYOUT_SPACE_WEIGHT = 0.1;
 
 const BACKGROUND_CORNER_RADIUS_PIXELS = 30;
-const BACKGROUND_SCALE = 0.94;
+const BACKGROUND_MARGIN = 12;
 
 // Window Thumbnail Layout Algorithm
 // =================================
@@ -938,13 +938,16 @@ class WorkspaceBackground extends St.Widget {
     }
 
     vfunc_allocate(box) {
-        const scaledBox = box.copy();
-        scaledBox.scale(BACKGROUND_SCALE);
+        const [width, height] = box.get_size();
+        const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
+        const scaledHeight = height - (BACKGROUND_MARGIN * 2 * scaleFactor);
+        const scaledWidth = (scaledHeight / height) * width;
 
-        const [scaledWidth, scaledHeight] = scaledBox.get_size();
+        const scaledBox = box.copy();
         scaledBox.set_origin(
-            box.x1 + (box.get_width() - scaledWidth) / 2,
-            box.y1 + (box.get_height() - scaledHeight) / 2);
+            box.x1 + (width - scaledWidth) / 2,
+            box.y1 + (height - scaledHeight) / 2);
+        scaledBox.set_size(scaledWidth, scaledHeight);
 
         const progress = this._stateAdjustment.value;
 


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