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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2939>
This commit is contained in:
parent
08eaf83141
commit
d8014090fd
@ -195,7 +195,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
this._workspacesThumbnails.get_preferred_height(width);
|
this._workspacesThumbnails.get_preferred_height(width);
|
||||||
thumbnailsHeight = Math.min(
|
thumbnailsHeight = Math.min(
|
||||||
thumbnailsHeight * expandFraction,
|
thumbnailsHeight * expandFraction,
|
||||||
height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE);
|
height * this._workspacesThumbnails.maxThumbnailScale);
|
||||||
childBox.set_origin(0, startY + searchHeight + spacing);
|
childBox.set_origin(0, startY + searchHeight + spacing);
|
||||||
childBox.set_size(width, thumbnailsHeight);
|
childBox.set_size(width, thumbnailsHeight);
|
||||||
this._workspacesThumbnails.allocate(childBox);
|
this._workspacesThumbnails.allocate(childBox);
|
||||||
|
@ -615,6 +615,7 @@ export const ThumbnailsBox = GObject.registerClass({
|
|||||||
this.add_actor(this._dropPlaceholder);
|
this.add_actor(this._dropPlaceholder);
|
||||||
this._spliceIndex = -1;
|
this._spliceIndex = -1;
|
||||||
|
|
||||||
|
this._maxThumbnailScale = MAX_THUMBNAIL_SCALE;
|
||||||
this._targetScale = 0;
|
this._targetScale = 0;
|
||||||
this._scale = 0;
|
this._scale = 0;
|
||||||
this._expandFraction = 1;
|
this._expandFraction = 1;
|
||||||
@ -675,6 +676,10 @@ export const ThumbnailsBox = GObject.registerClass({
|
|||||||
() => this._updateIndicator(), this);
|
() => this._updateIndicator(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get maxThumbnailScale() {
|
||||||
|
return this._maxThumbnailScale;
|
||||||
|
}
|
||||||
|
|
||||||
setMonitorIndex(monitorIndex) {
|
setMonitorIndex(monitorIndex) {
|
||||||
this._monitorIndex = monitorIndex;
|
this._monitorIndex = monitorIndex;
|
||||||
}
|
}
|
||||||
@ -1198,7 +1203,7 @@ export const ThumbnailsBox = GObject.registerClass({
|
|||||||
const avail = forWidth - totalSpacing;
|
const avail = forWidth - totalSpacing;
|
||||||
|
|
||||||
let scale = (avail / nWorkspaces) / this._porthole.width;
|
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);
|
const height = Math.round(this._porthole.height * scale);
|
||||||
return themeNode.adjust_preferred_height(height, height);
|
return themeNode.adjust_preferred_height(height, height);
|
||||||
@ -1223,7 +1228,7 @@ export const ThumbnailsBox = GObject.registerClass({
|
|||||||
workspaceSpacing += spacing / 2;
|
workspaceSpacing += spacing / 2;
|
||||||
|
|
||||||
const progress = 1 - thumbnail.collapse_fraction;
|
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;
|
return accumulator + width;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
@ -1290,10 +1295,10 @@ export const ThumbnailsBox = GObject.registerClass({
|
|||||||
const thumbnailHeight = thumbnailFullHeight * this._expandFraction;
|
const thumbnailHeight = thumbnailFullHeight * this._expandFraction;
|
||||||
const roundedVScale = thumbnailHeight / portholeHeight;
|
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
|
// space evently if we use smaller thumbnails
|
||||||
const extraWidth =
|
const extraWidth =
|
||||||
(MAX_THUMBNAIL_SCALE * portholeWidth - thumbnailWidth) * nWorkspaces;
|
(this._maxThumbnailScale * portholeWidth - thumbnailWidth) * nWorkspaces;
|
||||||
box.x1 += Math.round(extraWidth / 2);
|
box.x1 += Math.round(extraWidth / 2);
|
||||||
box.x2 -= Math.round(extraWidth / 2);
|
box.x2 -= Math.round(extraWidth / 2);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import * as OverviewControls from './overviewControls.js';
|
|||||||
import * as SwipeTracker from './swipeTracker.js';
|
import * as SwipeTracker from './swipeTracker.js';
|
||||||
import * as Util from '../misc/util.js';
|
import * as Util from '../misc/util.js';
|
||||||
import * as Workspace from './workspace.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;
|
const WORKSPACE_SWITCH_TIME = 250;
|
||||||
|
|
||||||
@ -651,7 +651,7 @@ class SecondaryMonitorDisplay extends St.Widget {
|
|||||||
const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width);
|
const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width);
|
||||||
return Math.min(
|
return Math.min(
|
||||||
thumbnailsHeight * expandFraction,
|
thumbnailsHeight * expandFraction,
|
||||||
height * MAX_THUMBNAIL_SCALE);
|
height * this._thumbnails.maxThumbnailScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {
|
_getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user