windowPreview: Add scaled extra size to chromeWidths() and chromeHeights

Right now the rowSpacing and columSpacing of the layout strategy is
calculated by looking at the overlapping sizes of the close button and
the app icon of the WindowPreview, plus a constant spacing read from CSS
by the WorkspaceLayout that's added to that. We're not factoring in the
extra size of the scaled-up WindowPreviews here and instead depend on
the constant spacing being large enough. If we don't want to depend on
the spacing here, we should add the scaled-up extra size to the sizes
returned by chromeWidths() and chromeHeights().

Since the last commits all previews scale up by the same amount of
pixels, so we can now just add that size to the values returned by
chromeWidths() and chromeHeights().

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1692>
This commit is contained in:
Jonas Dreßler 2021-02-08 19:06:37 +01:00 committed by Marge Bot
parent 7d40930cd6
commit bc034d5553
2 changed files with 12 additions and 11 deletions

View File

@ -466,15 +466,22 @@ var WindowPreview = GObject.registerClass({
chromeHeights() { chromeHeights() {
const [, closeButtonHeight] = this._closeButton.get_preferred_height(-1); const [, closeButtonHeight] = this._closeButton.get_preferred_height(-1);
const [, iconHeight] = this._icon.get_preferred_height(-1); const [, iconHeight] = this._icon.get_preferred_height(-1);
const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * scaleFactor;
const topOversize = closeButtonHeight / 2; const topOversize = closeButtonHeight / 2;
const bottomOversize = (1 - ICON_OVERLAP) * iconHeight; const bottomOversize = (1 - ICON_OVERLAP) * iconHeight;
return [topOversize, bottomOversize]; return [
topOversize + activeExtraSize,
bottomOversize + activeExtraSize,
];
} }
chromeWidths() { chromeWidths() {
const [, closeButtonWidth] = this._closeButton.get_preferred_width(-1); const [, closeButtonWidth] = this._closeButton.get_preferred_width(-1);
const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * scaleFactor;
const leftOversize = this._closeButtonSide === St.Side.LEFT const leftOversize = this._closeButtonSide === St.Side.LEFT
? closeButtonWidth / 2 ? closeButtonWidth / 2
@ -483,7 +490,10 @@ var WindowPreview = GObject.registerClass({
? 0 ? 0
: closeButtonWidth / 2; : closeButtonWidth / 2;
return [leftOversize, rightOversize]; return [
leftOversize + activeExtraSize,
rightOversize + activeExtraSize,
];
} }
showOverlay(animate) { showOverlay(animate) {

View File

@ -12,7 +12,6 @@ const Util = imports.misc.util;
const { WindowPreview } = imports.ui.windowPreview; const { WindowPreview } = imports.ui.windowPreview;
var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95;
var MAXIMUM_PREVIEW_AREA = 0.98;
var WINDOW_REPOSITIONING_DELAY = 750; var WINDOW_REPOSITIONING_DELAY = 750;
@ -470,14 +469,6 @@ var WorkspaceLayout = GObject.registerClass({
colSpacing += Math.max(leftOversize, rightOversize); colSpacing += Math.max(leftOversize, rightOversize);
if (containerBox) { if (containerBox) {
// add some padding around preview area
const [width, height] = containerBox.get_size();
containerBox.set_size(
width * MAXIMUM_PREVIEW_AREA,
height * MAXIMUM_PREVIEW_AREA);
containerBox.x1 += width * (1 - MAXIMUM_PREVIEW_AREA) / 2;
containerBox.y1 += height * (1 - MAXIMUM_PREVIEW_AREA) / 2;
const [topOverlap, bottomOverlap] = window.overlapHeights(); const [topOverlap, bottomOverlap] = window.overlapHeights();
containerBox.x1 += leftOversize + topOverlap; containerBox.x1 += leftOversize + topOverlap;
containerBox.x2 -= rightOversize; containerBox.x2 -= rightOversize;