workspace: Pass params object to LayoutStrategy
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1617>
This commit is contained in:
parent
ec0d8e3a72
commit
c635ff490a
@ -7,6 +7,7 @@ const Background = imports.ui.background;
|
|||||||
const DND = imports.ui.dnd;
|
const DND = imports.ui.dnd;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const Overview = imports.ui.overview;
|
const Overview = imports.ui.overview;
|
||||||
|
const Params = imports.misc.params;
|
||||||
const { WindowPreview } = imports.ui.windowPreview;
|
const { WindowPreview } = imports.ui.windowPreview;
|
||||||
|
|
||||||
var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95;
|
var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95;
|
||||||
@ -98,13 +99,19 @@ function _interpolate(start, end, step) {
|
|||||||
// and center it horizontally, and align it to the bottom vertically.
|
// and center it horizontally, and align it to the bottom vertically.
|
||||||
|
|
||||||
var LayoutStrategy = class {
|
var LayoutStrategy = class {
|
||||||
constructor(monitor, rowSpacing, columnSpacing) {
|
constructor(params) {
|
||||||
if (this.constructor === LayoutStrategy)
|
params = Params.parse(params, {
|
||||||
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
|
monitor: null,
|
||||||
|
rowSpacing: 0,
|
||||||
|
columnSpacing: 0,
|
||||||
|
});
|
||||||
|
|
||||||
this._monitor = monitor;
|
if (!params.monitor)
|
||||||
this._rowSpacing = rowSpacing;
|
throw new Error(`No monitor param passed to ${this.constructor.name}`);
|
||||||
this._columnSpacing = columnSpacing;
|
|
||||||
|
this._monitor = params.monitor;
|
||||||
|
this._rowSpacing = params.rowSpacing;
|
||||||
|
this._columnSpacing = params.columnSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
_newRow() {
|
_newRow() {
|
||||||
@ -474,15 +481,16 @@ var WorkspaceLayout = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_createBestLayout(area) {
|
_createBestLayout(area) {
|
||||||
const [rowSpacing, colSpacing] =
|
const [rowSpacing, columnSpacing] =
|
||||||
this._adjustSpacingAndPadding(this._spacing, this._spacing, null);
|
this._adjustSpacingAndPadding(this._spacing, this._spacing, null);
|
||||||
|
|
||||||
// We look for the largest scale that allows us to fit the
|
// We look for the largest scale that allows us to fit the
|
||||||
// largest row/tallest column on the workspace.
|
// largest row/tallest column on the workspace.
|
||||||
const strategy = new UnalignedLayoutStrategy(
|
const strategy = new UnalignedLayoutStrategy({
|
||||||
Main.layoutManager.monitors[this._monitorIndex],
|
monitor: Main.layoutManager.monitors[this._monitorIndex],
|
||||||
rowSpacing,
|
rowSpacing,
|
||||||
colSpacing);
|
columnSpacing,
|
||||||
|
});
|
||||||
|
|
||||||
let lastLayout = {};
|
let lastLayout = {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user