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>
This commit is contained in:
Jonas Dreßler 2021-02-22 12:50:29 +01:00 committed by Marge Bot
parent df9129b2a0
commit 99378b6dae

View File

@ -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;