ControlsManagerLayout: Allocate respecting the work area
We build controls layout using the whole monitor vertical space as available, however extensions or external apps in X11 may reduce the workarea size horizontally and the shell should always take care of it. Given that we're already assuming that the allocation is monitor-based and that we're adjusting it to the workarea, we can just make it more explicit by using a workarea box that is used as the allocation area. As per this, we also apply the same logic of applied to the vertical dimension to the horizontal one. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1892>
This commit is contained in:
parent
2b074882f4
commit
81a1e294f8
@ -47,8 +47,9 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
stateAdjustment.connect('notify::value', () => this.layout_changed());
|
stateAdjustment.connect('notify::value', () => this.layout_changed());
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeWorkspacesBoxForState(state, box, startY, searchHeight, dashHeight, thumbnailsHeight) {
|
_computeWorkspacesBoxForState(state, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
|
||||||
const workspaceBox = box.copy();
|
const workspaceBox = workAreaBox.copy();
|
||||||
|
const [startX, startY] = workAreaBox.get_origin();
|
||||||
const [width, height] = workspaceBox.get_size();
|
const [width, height] = workspaceBox.get_size();
|
||||||
const { spacing } = this;
|
const { spacing } = this;
|
||||||
const { expandFraction } = this._workspacesThumbnails;
|
const { expandFraction } = this._workspacesThumbnails;
|
||||||
@ -57,7 +58,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
case ControlsState.HIDDEN:
|
case ControlsState.HIDDEN:
|
||||||
break;
|
break;
|
||||||
case ControlsState.WINDOW_PICKER:
|
case ControlsState.WINDOW_PICKER:
|
||||||
workspaceBox.set_origin(0,
|
workspaceBox.set_origin(startX,
|
||||||
startY + searchHeight + spacing +
|
startY + searchHeight + spacing +
|
||||||
thumbnailsHeight + spacing * expandFraction);
|
thumbnailsHeight + spacing * expandFraction);
|
||||||
workspaceBox.set_size(width,
|
workspaceBox.set_size(width,
|
||||||
@ -67,7 +68,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
thumbnailsHeight - spacing * expandFraction);
|
thumbnailsHeight - spacing * expandFraction);
|
||||||
break;
|
break;
|
||||||
case ControlsState.APP_GRID:
|
case ControlsState.APP_GRID:
|
||||||
workspaceBox.set_origin(0, startY + searchHeight + spacing);
|
workspaceBox.set_origin(startX, startY + searchHeight + spacing);
|
||||||
workspaceBox.set_size(
|
workspaceBox.set_size(
|
||||||
width,
|
width,
|
||||||
Math.round(height * SMALL_WORKSPACE_RATIO));
|
Math.round(height * SMALL_WORKSPACE_RATIO));
|
||||||
@ -77,18 +78,19 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
return workspaceBox;
|
return workspaceBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getAppDisplayBoxForState(state, box, startY, searchHeight, dashHeight, appGridBox) {
|
_getAppDisplayBoxForState(state, workAreaBox, searchHeight, dashHeight, appGridBox) {
|
||||||
const [width, height] = box.get_size();
|
const [startX, startY] = workAreaBox.get_origin();
|
||||||
|
const [width, height] = workAreaBox.get_size();
|
||||||
const appDisplayBox = new Clutter.ActorBox();
|
const appDisplayBox = new Clutter.ActorBox();
|
||||||
const { spacing } = this;
|
const { spacing } = this;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ControlsState.HIDDEN:
|
case ControlsState.HIDDEN:
|
||||||
case ControlsState.WINDOW_PICKER:
|
case ControlsState.WINDOW_PICKER:
|
||||||
appDisplayBox.set_origin(0, box.y2);
|
appDisplayBox.set_origin(startX, workAreaBox.y2);
|
||||||
break;
|
break;
|
||||||
case ControlsState.APP_GRID:
|
case ControlsState.APP_GRID:
|
||||||
appDisplayBox.set_origin(0,
|
appDisplayBox.set_origin(startX,
|
||||||
startY + searchHeight + spacing + appGridBox.get_height());
|
startY + searchHeight + spacing + appGridBox.get_height());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -126,34 +128,37 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_allocate(container, box) {
|
vfunc_allocate(_container, _box) {
|
||||||
const childBox = new Clutter.ActorBox();
|
const childBox = new Clutter.ActorBox();
|
||||||
|
|
||||||
const { spacing } = this;
|
const { spacing } = this;
|
||||||
|
|
||||||
const monitor = Main.layoutManager.findMonitorForActor(this._container);
|
const monitor = Main.layoutManager.findMonitorForActor(this._container);
|
||||||
const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
|
const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
|
||||||
|
const startX = workArea.x - monitor.x;
|
||||||
const startY = workArea.y - monitor.y;
|
const startY = workArea.y - monitor.y;
|
||||||
box.y1 += startY;
|
const workAreaBox = new Clutter.ActorBox();
|
||||||
box.y2 -= (monitor.height - workArea.height) - startY;
|
workAreaBox.set_origin(startX, startY);
|
||||||
const [width, height] = box.get_size();
|
workAreaBox.set_size(workArea.width, workArea.height);
|
||||||
|
const [width, height] = workAreaBox.get_size();
|
||||||
let availableHeight = height;
|
let availableHeight = height;
|
||||||
|
const availableWidth = width;
|
||||||
|
|
||||||
// Search entry
|
// Search entry
|
||||||
let [searchHeight] = this._searchEntry.get_preferred_height(width);
|
let [searchHeight] = this._searchEntry.get_preferred_height(width);
|
||||||
childBox.set_origin(0, startY);
|
childBox.set_origin(startX, startY);
|
||||||
childBox.set_size(width, searchHeight);
|
childBox.set_size(width, searchHeight);
|
||||||
this._searchEntry.allocate(childBox);
|
this._searchEntry.allocate(childBox);
|
||||||
|
|
||||||
availableHeight -= searchHeight + spacing;
|
availableHeight -= searchHeight + spacing;
|
||||||
|
|
||||||
// Dash
|
// Dash
|
||||||
const maxDashHeight = Math.round(box.get_height() * DASH_MAX_HEIGHT_RATIO);
|
const maxDashHeight = Math.round(workAreaBox.get_height() * DASH_MAX_HEIGHT_RATIO);
|
||||||
this._dash.setMaxSize(width, maxDashHeight);
|
this._dash.setMaxSize(width, maxDashHeight);
|
||||||
|
|
||||||
let [, dashHeight] = this._dash.get_preferred_height(width);
|
let [, dashHeight] = this._dash.get_preferred_height(width);
|
||||||
dashHeight = Math.min(dashHeight, maxDashHeight);
|
dashHeight = Math.min(dashHeight, maxDashHeight);
|
||||||
childBox.set_origin(0, startY + height - dashHeight);
|
childBox.set_origin(startX, startY + height - dashHeight);
|
||||||
childBox.set_size(width, dashHeight);
|
childBox.set_size(width, dashHeight);
|
||||||
this._dash.allocate(childBox);
|
this._dash.allocate(childBox);
|
||||||
|
|
||||||
@ -168,13 +173,13 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
thumbnailsHeight = Math.min(
|
thumbnailsHeight = Math.min(
|
||||||
thumbnailsHeight * expandFraction,
|
thumbnailsHeight * expandFraction,
|
||||||
height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE);
|
height * WorkspaceThumbnail.MAX_THUMBNAIL_SCALE);
|
||||||
childBox.set_origin(0, startY + searchHeight + spacing);
|
childBox.set_origin(startX, startY + searchHeight + spacing);
|
||||||
childBox.set_size(width, thumbnailsHeight);
|
childBox.set_size(width, thumbnailsHeight);
|
||||||
this._workspacesThumbnails.allocate(childBox);
|
this._workspacesThumbnails.allocate(childBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workspaces
|
// Workspaces
|
||||||
let params = [box, startY, searchHeight, dashHeight, thumbnailsHeight];
|
let params = [workAreaBox, searchHeight, dashHeight, thumbnailsHeight];
|
||||||
const transitionParams = this._stateAdjustment.getStateTransitionParams();
|
const transitionParams = this._stateAdjustment.getStateTransitionParams();
|
||||||
|
|
||||||
// Update cached boxes
|
// Update cached boxes
|
||||||
@ -199,7 +204,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
const workspaceAppGridBox =
|
const workspaceAppGridBox =
|
||||||
this._cachedWorkspaceBoxes.get(ControlsState.APP_GRID);
|
this._cachedWorkspaceBoxes.get(ControlsState.APP_GRID);
|
||||||
|
|
||||||
params = [box, startY, searchHeight, dashHeight, workspaceAppGridBox];
|
params = [workAreaBox, searchHeight, dashHeight, workspaceAppGridBox];
|
||||||
let appDisplayBox;
|
let appDisplayBox;
|
||||||
if (!transitionParams.transitioning) {
|
if (!transitionParams.transitioning) {
|
||||||
appDisplayBox =
|
appDisplayBox =
|
||||||
@ -217,8 +222,8 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
childBox.set_origin(0, startY + searchHeight + spacing);
|
childBox.set_origin(startX, startY + searchHeight + spacing);
|
||||||
childBox.set_size(width, availableHeight);
|
childBox.set_size(availableWidth, availableHeight);
|
||||||
|
|
||||||
this._searchController.allocate(childBox);
|
this._searchController.allocate(childBox);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user