From bc034d55531b8762169bc2ef56178a3c003889b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 8 Feb 2021 19:06:37 +0100 Subject: [PATCH] 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: --- js/ui/windowPreview.js | 14 ++++++++++++-- js/ui/workspace.js | 9 --------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js index 252778948..1659d0077 100644 --- a/js/ui/windowPreview.js +++ b/js/ui/windowPreview.js @@ -466,15 +466,22 @@ var WindowPreview = GObject.registerClass({ chromeHeights() { const [, closeButtonHeight] = this._closeButton.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 bottomOversize = (1 - ICON_OVERLAP) * iconHeight; - return [topOversize, bottomOversize]; + return [ + topOversize + activeExtraSize, + bottomOversize + activeExtraSize, + ]; } chromeWidths() { 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 ? closeButtonWidth / 2 @@ -483,7 +490,10 @@ var WindowPreview = GObject.registerClass({ ? 0 : closeButtonWidth / 2; - return [leftOversize, rightOversize]; + return [ + leftOversize + activeExtraSize, + rightOversize + activeExtraSize, + ]; } showOverlay(animate) { diff --git a/js/ui/workspace.js b/js/ui/workspace.js index e75d64377..403c5dded 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -12,7 +12,6 @@ const Util = imports.misc.util; const { WindowPreview } = imports.ui.windowPreview; var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; -var MAXIMUM_PREVIEW_AREA = 0.98; var WINDOW_REPOSITIONING_DELAY = 750; @@ -470,14 +469,6 @@ var WorkspaceLayout = GObject.registerClass({ colSpacing += Math.max(leftOversize, rightOversize); 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(); containerBox.x1 += leftOversize + topOverlap; containerBox.x2 -= rightOversize;