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>
This commit is contained in:
Sebastian Keller 2021-02-21 18:38:05 +01:00 committed by Marge Bot
parent ef777426d2
commit ef5b92c596

View File

@ -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 { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * 2 * scaleFactor; 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({ this._windowContainer.ease({
scale_x: scale, scale_x: scale,