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>
This commit is contained in:
Jonas Dreßler 2021-02-08 19:02:23 +01:00 committed by Marge Bot
parent 3795ccbcf3
commit 7d40930cd6

View File

@ -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,
});