From d8014090fdd22e0a46f2ad6f5ba712ad8950d25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 12 Aug 2023 00:32:35 +0200 Subject: [PATCH] workspaceThumbnail: Expose maxThumbnailScale as property Some extensions want to modify the value of the MAX_THUMBNAIL_SCALE constant. That is no longer possible, as exports are always read-only from the outside. Make this possible again by exposing the scale as a property on the object itself, so extensions can override it. Part-of: --- js/ui/overviewControls.js | 2 +- js/ui/workspaceThumbnail.js | 13 +++++++++---- js/ui/workspacesView.js | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js index f5ef43347..615b4b40b 100644 --- a/js/ui/overviewControls.js +++ b/js/ui/overviewControls.js @@ -195,7 +195,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout { this._workspacesThumbnails.get_preferred_height(width); thumbnailsHeight = Math.min( thumbnailsHeight * expandFraction, - height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE); + height * this._workspacesThumbnails.maxThumbnailScale); childBox.set_origin(0, startY + searchHeight + spacing); childBox.set_size(width, thumbnailsHeight); this._workspacesThumbnails.allocate(childBox); diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index e56acecbe..75db8111b 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -615,6 +615,7 @@ export const ThumbnailsBox = GObject.registerClass({ this.add_actor(this._dropPlaceholder); this._spliceIndex = -1; + this._maxThumbnailScale = MAX_THUMBNAIL_SCALE; this._targetScale = 0; this._scale = 0; this._expandFraction = 1; @@ -675,6 +676,10 @@ export const ThumbnailsBox = GObject.registerClass({ () => this._updateIndicator(), this); } + get maxThumbnailScale() { + return this._maxThumbnailScale; + } + setMonitorIndex(monitorIndex) { this._monitorIndex = monitorIndex; } @@ -1198,7 +1203,7 @@ export const ThumbnailsBox = GObject.registerClass({ const avail = forWidth - totalSpacing; let scale = (avail / nWorkspaces) / this._porthole.width; - scale = Math.min(scale, MAX_THUMBNAIL_SCALE); + scale = Math.min(scale, this._maxThumbnailScale); const height = Math.round(this._porthole.height * scale); return themeNode.adjust_preferred_height(height, height); @@ -1223,7 +1228,7 @@ export const ThumbnailsBox = GObject.registerClass({ workspaceSpacing += spacing / 2; const progress = 1 - thumbnail.collapse_fraction; - const width = (this._porthole.width * MAX_THUMBNAIL_SCALE + workspaceSpacing) * progress; + const width = (this._porthole.width * this._maxThumbnailScale + workspaceSpacing) * progress; return accumulator + width; }, 0); @@ -1290,10 +1295,10 @@ export const ThumbnailsBox = GObject.registerClass({ const thumbnailHeight = thumbnailFullHeight * this._expandFraction; const roundedVScale = thumbnailHeight / portholeHeight; - // We always request size for MAX_THUMBNAIL_SCALE, distribute + // We always request size for maxThumbnailScale, distribute // space evently if we use smaller thumbnails const extraWidth = - (MAX_THUMBNAIL_SCALE * portholeWidth - thumbnailWidth) * nWorkspaces; + (this._maxThumbnailScale * portholeWidth - thumbnailWidth) * nWorkspaces; box.x1 += Math.round(extraWidth / 2); box.x2 -= Math.round(extraWidth / 2); diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index cddb40904..5d58542f9 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -15,7 +15,7 @@ import * as OverviewControls from './overviewControls.js'; import * as SwipeTracker from './swipeTracker.js'; import * as Util from '../misc/util.js'; import * as Workspace from './workspace.js'; -import {ThumbnailsBox, MAX_THUMBNAIL_SCALE} from './workspaceThumbnail.js'; +import {ThumbnailsBox} from './workspaceThumbnail.js'; const WORKSPACE_SWITCH_TIME = 250; @@ -651,7 +651,7 @@ class SecondaryMonitorDisplay extends St.Widget { const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width); return Math.min( thumbnailsHeight * expandFraction, - height * MAX_THUMBNAIL_SCALE); + height * this._thumbnails.maxThumbnailScale); } _getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {