Skip to content

Commit

Permalink
docking: Do ControlsManagerLayout allocation with box-adjusted workArea
Browse files Browse the repository at this point in the history
We were allocating the ControlsManagerLayout using the whole work area
geometry but then in the auto-hide mode we were reducing the size of the
available area again, creating problems when the available space was
reduced. Leading to non-clickable or activatable search results.

To prevent this, perform layout allocation using the available space
even when the dock is in autohide mode.

Closes: #1612
LP: #1979096
  • Loading branch information
3v1n0 committed Jun 2, 2023
1 parent 52c3f96 commit 581a101
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -2175,9 +2175,7 @@ var DockManager = class DashToDock_DockManager {
}
});

const maybeAdjustBoxToDock = (state, box, spacing) => {
const initialRatio = box.get_width() / box.get_height();

const maybeAdjustBoxSize = (state, box, spacing) => {
if (state === OverviewControls.ControlsState.WINDOW_PICKER) {
const searchBox = this.overviewControls._searchEntry.get_allocation_box();
const { shouldShow: wsThumbnails } = this.overviewControls._thumbnailsBox;
Expand All @@ -2191,19 +2189,24 @@ var DockManager = class DashToDock_DockManager {
box.y2 -= spacing;
}

return box;
};

const maybeAdjustBoxToDock = (state, box, spacing) => {
const initialRatio = box.get_width() / box.get_height();

maybeAdjustBoxSize(state, box, spacing);

if (this.mainDock.isHorizontal || this.settings.dockFixed)
return box;

let [, preferredWidth] = this.mainDock.get_preferred_width(box.get_height());

// For some reason we need to use an even value for the box area
// or we may end up in allocation issues:
// https://github.com/micheleg/dash-to-dock/issues/1612
preferredWidth = Math.floor(preferredWidth / 2.0) * 2
const [, preferredWidth] = this.mainDock.get_preferred_width(
box.get_height());

box.x2 -= preferredWidth;
if (this.mainDock.position === St.Side.LEFT)
box.set_origin(box.x1 + preferredWidth, box.y1);
box.x1 += preferredWidth;
else if (this.mainDock.position === St.Side.RIGHT)
box.x2 -= preferredWidth;

// Reduce the box height too, to keep the initial proportions
const heightAdjustment = (preferredWidth / initialRatio) / 2;
Expand All @@ -2226,17 +2229,19 @@ var DockManager = class DashToDock_DockManager {
workAreaBox.set_origin(startX, startY);
workAreaBox.set_size(workArea.width, workArea.height);

maybeAdjustBoxToDock(undefined, workAreaBox, this.spacing);
const oldStartY = workAreaBox.y1;

const propertyInjections = new Utils.PropertyInjectionsHandler();
propertyInjections.add(Main.layoutManager.panelBox, 'height', { value: workAreaBox.y1 });
propertyInjections.add(Main.layoutManager.panelBox, 'height', { value: startY });

if (Main.layoutManager.panelBox.y === Main.layoutManager.primaryMonitor.y)
workAreaBox.y1 -= startY;
workAreaBox.y1 -= oldStartY;

this.vfunc_allocate(container, workAreaBox);

propertyInjections.destroy();
workAreaBox.y1 = startY;
maybeAdjustBoxToDock(undefined, workAreaBox, this.spacing);
workAreaBox.y1 = oldStartY;

const adjustActorHorizontalAllocation = actor => {
if (!actor.visible || !workAreaBox.x1)
Expand Down Expand Up @@ -2266,19 +2271,22 @@ var DockManager = class DashToDock_DockManager {
ControlsManagerLayout.prototype,
'_computeWorkspacesBoxForState',
function (originalFunction, state, ...args) {
/* eslint-disable no-invalid-this */
if (state === OverviewControls.ControlsState.HIDDEN)
return originalFunction.call(this, state, ...args);

const box = workspaceBoxOriginFixer.call(this, originalFunction, state, ...args);
if (state !== OverviewControls.ControlsState.HIDDEN)
maybeAdjustBoxToDock(state, box, this.spacing);
return box;
}
return maybeAdjustBoxSize(state, box, this.spacing);
/* eslint-enable no-invalid-this */
},
], [
ControlsManagerLayout.prototype,
'_getAppDisplayBoxForState',
function (state, ...args) {
const { spacing } = this;
const box = workspaceBoxOriginFixer.call(this, state, ...args);
return maybeAdjustBoxToDock(state, box, spacing);
}
function (originalFunction, ...args) {
/* eslint-disable no-invalid-this */
return workspaceBoxOriginFixer.call(this, originalFunction, ...args);
/* eslint-enable no-invalid-this */
},
]);

this._vfuncInjections.addWithLabel('main-dash', Workspace.WorkspaceBackground.prototype,
Expand Down

0 comments on commit 581a101

Please sign in to comment.