Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cosmic workspaces for Jammy jellyfish #51

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions overviewControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ function reset() {
}

var ControlsManagerLayoutOverride = {
_computeWorkspacesBoxForState: function (state, box, startY, searchHeight, leftOffset, rightOffset) {
const workspaceBox = box.copy();
_computeWorkspacesBoxForState(state, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
const workspaceBox = workAreaBox.copy();
const [startX, startY] = workAreaBox.get_origin();
const [width, height] = workspaceBox.get_size();

const { spacing } = this;
const { expandFraction } = this._workspacesThumbnails;

Expand Down Expand Up @@ -94,29 +96,30 @@ var ControlsManagerLayoutOverride = {
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
workspaceBox.set_origin(
leftOffset + translate_x,
this.leftOffset + translate_x,
startY + searchHeight + spacing * expandFraction);
workspaceBox.set_size(
width - leftOffset - rightOffset - (spacing * 2),
width - this.leftOffset - this.rightOffset - (spacing * 2),
height - startY - (searchHeight + spacing * expandFraction) * 2);
break;
}

return workspaceBox;
},

_getAppDisplayBoxForState: function(state, box, startY, searchHeight) {
const [width, height] = box.get_size();
_getAppDisplayBoxForState(state, workAreaBox, searchHeight, dashHeight, appGridBox) {
const [startX, startY] = workAreaBox.get_origin();
const [width, height] = workAreaBox.get_size();
const appDisplayBox = new Clutter.ActorBox();
const { spacing } = this;

switch (state) {
case ControlsState.HIDDEN:
case ControlsState.WINDOW_PICKER:
appDisplayBox.set_origin(0, box.y2);
appDisplayBox.set_origin(startX, workspaceBox.y2);
break;
case ControlsState.APP_GRID:
appDisplayBox.set_origin(0,
appDisplayBox.set_origin(startX,
startY + searchHeight + spacing);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function overrideProto(proto, overrides) {

for (var symbol in overrides) {
if (symbol.startsWith('after_')) {
const actualSymbol = symbol.substr('after_'.length);
const actualSymbol = symbol.slice('after_'.length);
const fn = proto[actualSymbol];
const afterFn = overrides[symbol]
proto[actualSymbol] = function() {
Expand All @@ -29,7 +29,7 @@ function overrideProto(proto, overrides) {
else {
backup[symbol] = proto[symbol];
if (symbol.startsWith('vfunc')) {
hookVfunc(proto, symbol.substr(6), overrides[symbol]);
hookVfunc(proto[Gi.gobject_prototype_symbol], symbol.slice(6), overrides[symbol]);
}
else {
proto[symbol] = overrides[symbol];
Expand Down
96 changes: 1 addition & 95 deletions workspacesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const Util = Self.imports.util;

function override() {
global.vertical_overview.GSFunctions['WorkspacesView'] = Util.overrideProto(WorkspacesView.WorkspacesView.prototype, WorkspacesViewOverride);
log('You may see an error below,\nSecondaryMonitorDisplay is defined as const for some reason.\nSince I\'m overriding values in that const an error show might show up.\n Feel free to ignore it');
global.vertical_overview.GSFunctions['SecondaryMonitorDisplay'] = Util.overrideProto(WorkspacesView.SecondaryMonitorDisplay.prototype, SecondaryMonitorDisplayOverride);
log('Thank you, please carry on');

if (global.vertical_overview.default_old_style_enabled) {
Main.overview._overview._controls._workspacesDisplay.add_style_class_name("vertical-overview");
Expand Down Expand Up @@ -89,95 +86,4 @@ var WorkspacesViewOverride = {

return fitSingleBox;
}
}

var SecondaryMonitorDisplayOverride = {
_getWorkspacesBoxForState(state, box, padding, leftOffset, rightOffset, spacing) {
const { ControlsState } = OverviewControls;
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();

switch (state) {
case ControlsState.HIDDEN:
break;
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
workspaceBox.set_origin(leftOffset, padding + spacing);
workspaceBox.set_size(
width - rightOffset - leftOffset,
height - 2 * padding - spacing);
break;
}

return workspaceBox;
},

vfunc_allocate(box) {
this.set_allocation(box);

const themeNode = this.get_theme_node();
const contentBox = themeNode.get_content_box(box);
const [width, height] = contentBox.get_size();
const { expandFraction } = this._thumbnails;
const spacing = themeNode.get_length('spacing') * expandFraction;
const padding =
Math.round((1 - SECONDARY_WORKSPACE_SCALE) * height / 2);

const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
const scale = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).width / Main.layoutManager.primaryMonitor.width;
const leftOffset = Main.overview._overview._controls.layoutManager.leftOffset * scale * scaleFactor;
const rightOffset = Main.overview._overview._controls.layoutManager.rightOffset * scale * scaleFactor;

// Workspace Thumbnails
if (this._thumbnails.visible) {
const childBox = new Clutter.ActorBox();
let origin, size;
if (global.vertical_overview.workspace_picker_left) {
origin = [0, 0];
size = [leftOffset, height];
} else {
origin = [width - rightOffset, 0];
size = [rightOffset, height];
}

const cosmicDock = Util.getDock();
if (cosmicDock) {
const mainDock = cosmicDock.stateObj.dockManager.mainDock;

const [, dashHeight] = mainDock.get_preferred_height(width);
const [, dashWidth] = mainDock.get_preferred_width(height);

if (mainDock.position == St.Side.BOTTOM) {
size[1] -= dashHeight;
} else if (mainDock.position == St.Side.LEFT && global.vertical_overview.workspace_picker_left) {
origin[0] += dashWidth;
} else if (mainDock.position == St.Side.RIGHT && !global.vertical_overview.workspace_picker_left) {
origin[0] -= dashWidth;
}
}

childBox.set_origin(...origin);
childBox.set_size(...size);

this._thumbnails.allocate(childBox);
}

const {
currentState, initialState, finalState, transitioning, progress,
} = this._overviewAdjustment.getStateTransitionParams();

let workspacesBox;
const workspaceParams = [contentBox, padding, leftOffset, rightOffset, spacing];
if (!transitioning) {
workspacesBox =
this._getWorkspacesBoxForState(currentState, ...workspaceParams);
} else {
const initialBox =
this._getWorkspacesBoxForState(initialState, ...workspaceParams);
const finalBox =
this._getWorkspacesBoxForState(finalState, ...workspaceParams);
workspacesBox = initialBox.interpolate(finalBox, progress);
}
this._workspacesView.allocate(workspacesBox);
}
}
}