Revert to gs overview allocation since it now accounts for external struts

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1892/diffs
This commit is contained in:
Charles Gagnon
2022-04-03 11:14:01 -04:00
parent 15f9e0b072
commit e544d2c7af
2 changed files with 3 additions and 178 deletions

View File

@@ -69,7 +69,6 @@ var Overview = class {
this._optionalNumberOverlay();
this._optionalClickToExit();
this._toggleDash();
this._hookupAllocation();
this._signalsHandler.add([
Me.settings,
@@ -80,9 +79,6 @@ var Overview = class {
}
disable() {
Utils.hookVfunc(OverviewControls.ControlsManagerLayout.prototype, 'allocate', OverviewControls.ControlsManagerLayout.prototype.vfunc_allocate);
OverviewControls.ControlsManagerLayout.prototype._computeWorkspacesBoxForState = this._oldComputeWorkspacesBoxForState;
this._signalsHandler.destroy();
this._injectionsHandler.destroy();
@@ -480,177 +476,4 @@ var Overview = class {
return true;
}
_hookupAllocation() {
Utils.hookVfunc(OverviewControls.ControlsManagerLayout.prototype, 'allocate', function vfunc_allocate(container, box) {
const childBox = new Clutter.ActorBox();
const { spacing } = this;
let startY = 0;
let startX = 0;
if (Me.settings.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.panelBox.y === Main.layoutManager.primaryMonitor.y) {
startY = Main.layoutManager.panelBox.height;
box.y1 += startY;
}
const panel = global.dashToPanel.panels[0];
if(panel) {
switch (panel.getPosition()) {
case St.Side.TOP:
startY = panel.panelBox.height;
box.y1 += startY;
break;
case St.Side.LEFT:
startX = panel.panelBox.width;
box.x1 += startX;
break;
case St.Side.RIGHT:
box.x2 -= panel.panelBox.width;
break;
}
}
const [width, height] = box.get_size();
let availableHeight = height;
// Search entry
let [searchHeight] = this._searchEntry.get_preferred_height(width);
childBox.set_origin(startX, startY);
childBox.set_size(width, searchHeight);
this._searchEntry.allocate(childBox);
availableHeight -= searchHeight + spacing;
// Dash
const maxDashHeight = Math.round(box.get_height() * DASH_MAX_HEIGHT_RATIO);
this._dash.setMaxSize(width, maxDashHeight);
let [, dashHeight] = this._dash.get_preferred_height(width);
if (Me.settings.get_boolean('stockgs-keep-dash'))
dashHeight = Math.min(dashHeight, maxDashHeight);
else
dashHeight = spacing*5; // todo: determine proper spacing for window labels on maximized windows on workspace display
childBox.set_origin(startX, startY + height - dashHeight);
childBox.set_size(width, dashHeight);
this._dash.allocate(childBox);
availableHeight -= dashHeight + spacing;
// Workspace Thumbnails
let thumbnailsHeight = 0;
if (this._workspacesThumbnails.visible) {
const { expandFraction } = this._workspacesThumbnails;
[thumbnailsHeight] =
this._workspacesThumbnails.get_preferred_height(width);
thumbnailsHeight = Math.min(
thumbnailsHeight * expandFraction,
height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE);
childBox.set_origin(startX, startY + searchHeight + spacing);
childBox.set_size(width, thumbnailsHeight);
this._workspacesThumbnails.allocate(childBox);
}
// Workspaces
let params = [box, startX, startY, searchHeight, dashHeight, thumbnailsHeight];
const transitionParams = this._stateAdjustment.getStateTransitionParams();
// Update cached boxes
for (const state of Object.values(OverviewControls.ControlsState)) {
this._cachedWorkspaceBoxes.set(
state, this._computeWorkspacesBoxForState(state, ...params));
}
let workspacesBox;
if (!transitionParams.transitioning) {
workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState);
} else {
const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState);
const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState);
workspacesBox = initialBox.interpolate(finalBox, transitionParams.progress);
}
this._workspacesDisplay.allocate(workspacesBox);
// AppDisplay
if (this._appDisplay.visible) {
const workspaceAppGridBox =
this._cachedWorkspaceBoxes.get(OverviewControls.ControlsState.APP_GRID);
if (Config.PACKAGE_VERSION > '40.3') {
const monitor = Main.layoutManager.findMonitorForActor(this._container);
const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
const workAreaBox = new Clutter.ActorBox();
workAreaBox.set_origin(startX, startY);
workAreaBox.set_size(workArea.width, workArea.height);
if (Config.PACKAGE_VERSION < '42') {
params = [workAreaBox, searchHeight, dashHeight, workspaceAppGridBox]
} else {
params = [box, workAreaBox, searchHeight, dashHeight, workspaceAppGridBox]
}
} else {
params = [box, startX, searchHeight, dashHeight, workspaceAppGridBox];
}
let appDisplayBox;
if (!transitionParams.transitioning) {
appDisplayBox =
this._getAppDisplayBoxForState(transitionParams.currentState, ...params);
} else {
const initialBox =
this._getAppDisplayBoxForState(transitionParams.initialState, ...params);
const finalBox =
this._getAppDisplayBoxForState(transitionParams.finalState, ...params);
appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress);
}
this._appDisplay.allocate(appDisplayBox);
}
// Search
childBox.set_origin(0, startY + searchHeight + spacing);
childBox.set_size(width, availableHeight);
this._searchController.allocate(childBox);
this._runPostAllocation();
});
this._oldComputeWorkspacesBoxForState = OverviewControls.ControlsManagerLayout.prototype._computeWorkspacesBoxForState;
OverviewControls.ControlsManagerLayout.prototype._computeWorkspacesBoxForState = function _computeWorkspacesBoxForState(state, box, startX, startY, searchHeight, dashHeight, thumbnailsHeight) {
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
const { spacing } = this;
const { expandFraction } = this._workspacesThumbnails;
switch (state) {
case OverviewControls.ControlsState.HIDDEN:
break;
case OverviewControls.ControlsState.WINDOW_PICKER:
workspaceBox.set_origin(startX,
startY + searchHeight + spacing +
thumbnailsHeight + spacing * expandFraction);
workspaceBox.set_size(width,
height -
dashHeight - spacing -
searchHeight - spacing -
thumbnailsHeight - spacing * expandFraction);
break;
case OverviewControls.ControlsState.APP_GRID:
workspaceBox.set_origin(startX, startY + searchHeight + spacing);
workspaceBox.set_size(
width,
Math.round(height * SMALL_WORKSPACE_RATIO));
break;
}
return workspaceBox;
}
}
}