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

Support GJS 1.72 Shell 42 #217

Merged
merged 9 commits into from
Apr 28, 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
3 changes: 1 addition & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"shell-version": [
"40",
"41"
"42"
],
"uuid": "[email protected]",
"url": "https://github.com/mzur/gnome-shell-wsmatrix",
Expand Down
17 changes: 10 additions & 7 deletions [email protected]/overview/controlsManagerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Self = ExtensionUtils.getCurrentExtension();
const Util = Self.imports.util;
const OverviewControls = imports.ui.overviewControls;
const { ControlsState } = OverviewControls;

const { SMALL_WORKSPACE_RATIO } = OverviewControls;
//const { SMALL_WORKSPACE_RATIO } = OverviewControls;
const SMALL_WORKSPACE_RATIO = 0.15;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for Gnome Team to agree or disagree on opening this and other bits.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for Gnome Team to agree or disagree on opening this and other bits.

Did you open an issue or merge request at https://gitlab.gnome.org/GNOME/gnome-shell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here

Or just a patch (apply with patch -p1).


var ControlsManagerLayout = class {
constructor() {
this.originalLayout = null;
this._overrideProperties = {
_computeWorkspacesBoxForState(state, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incompatible change. @mzur, would you please open a shell-42 branch (or take this as it)?

const { ControlsState } = OverviewControls;
const workspaceBox = workAreaBox.copy();
const [startX, startY] = workAreaBox.get_origin();
_computeWorkspacesBoxForState(state, box, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
const { y1: startY } = workAreaBox;
const {spacing} = this;
const {expandFraction} = this._workspacesThumbnails;
let workspaceManager = global.workspace_manager;
let rows = workspaceManager.layout_rows;

switch (state) {
case ControlsState.HIDDEN:
workspaceBox.set_origin(...workAreaBox.get_origin());
workspaceBox.set_size(...workAreaBox.get_size());
break;
case ControlsState.WINDOW_PICKER:
workspaceBox.set_origin(startX,
workspaceBox.set_origin(0,
startY + searchHeight + spacing +
thumbnailsHeight * rows + spacing * expandFraction);
workspaceBox.set_size(width,
Expand All @@ -33,7 +36,7 @@ var ControlsManagerLayout = class {
thumbnailsHeight * rows - spacing * expandFraction);
break;
case ControlsState.APP_GRID:
workspaceBox.set_origin(startX, startY + searchHeight + spacing);
workspaceBox.set_origin(0, startY + searchHeight + spacing);
workspaceBox.set_size(
width,
Math.round(height * rows * SMALL_WORKSPACE_RATIO));
Expand Down
7 changes: 5 additions & 2 deletions [email protected]/overview/overviewManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ var OverviewManager = class {
this._thumbnailsBoxOverride.overrideOriginalProperties();
this._workspacesViewOverride.overrideOriginalProperties();
this._controlsManagerLayoutOverride.overrideOriginalProperties();
this._secondaryMonitorDisplayOverride.overrideOriginalProperties();
// Disabled until override objects can be imported again
// see: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2266
// this._secondaryMonitorDisplayOverride.overrideOriginalProperties();
}

restore() {
this._thumbnailsBoxOverride.restoreOriginalProperties();
this._workspacesViewOverride.restoreOriginalProperties();
this._controlsManagerLayoutOverride.restoreOriginalProperties();
this._secondaryMonitorDisplayOverride.restoreOriginalProperties();
// Disabled (see above).
// this._secondaryMonitorDisplayOverride.restoreOriginalProperties();
}

destroy() {
Expand Down
Binary file modified [email protected]/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</enum>
<schema id="org.gnome.shell.extensions.wsmatrix-settings" path="/org/gnome/shell/extensions/wsmatrix/">
<key type="i" name="num-columns">
<default>3</default>
<default>2</default>
<range min="1" max="36"/>
<summary>Number of columns of workspaces</summary>
</key>
<key type="i" name="num-rows">
<default>3</default>
<default>2</default>
<range min="1" max="36"/>
<summary>Number of rows of workspaces</summary>
</key>
<key type="i" name="popup-timeout">
<default>10</default>
<default>500</default>
<range min="0" max="5000"/>
<summary>Time to show the popup (ms)</summary>
</key>
Expand All @@ -35,7 +35,7 @@
<summary>Whether to allow hovering on workspaces in popup or not</summary>
</key>
<key type="b" name="show-workspace-names">
<default>true</default>
<default>false</default>
<summary>Whether to show workspace names or not</summary>
</key>
<key name="wraparound-mode" enum="org.gnome.shell.extensions.wsmatrix.wraparoundMode">
Expand Down
2 changes: 1 addition & 1 deletion [email protected]/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Gio = imports.gi.Gio;
const Self = imports.misc.extensionUtils.getCurrentExtension();

function hookVfunc(proto, symbol, func) {
proto[Gi.hook_up_vfunc_symbol](symbol, func);
proto[Gi.hook_up_vfunc_symbol].call(proto[Gi.gobject_prototype_symbol], symbol, func);
}

function overrideProto(proto, overrides) {
Expand Down
140 changes: 128 additions & 12 deletions [email protected]/workspacePopup/workspaceAnimation.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,105 @@
const {GObject, Meta, St} = imports.gi;
const {Clutter, GObject, Meta, St} = imports.gi;

const Main = imports.ui.main;
const GWorkspaceAnimation = imports.ui.workspaceAnimation;
const Layout = imports.ui.layout;
const ExtensionUtils = imports.misc.extensionUtils;
const Self = ExtensionUtils.getCurrentExtension();
const Util = Self.imports.util;
// const {WORKSPACE_SPACING} = GWorkspaceAnimation;
const WORKSPACE_SPACING = 100;

const MonitorGroup = GObject.registerClass({
Properties: {
'progress': GObject.ParamSpec.double(
'progress', 'progress', 'progress',
GObject.ParamFlags.READWRITE,
-Infinity, Infinity, 0),
},
}, class MonitorGroup extends St.Widget {
get baseDistance() {
const spacing = WORKSPACE_SPACING * St.ThemeContext.get_for_stage(global.stage).scale_factor;

if (global.workspace_manager.layout_rows === -1)
return this._monitor.height + spacing;
else
return this._monitor.width + spacing;
}

get index() {
return this._monitor.index;
}

getWorkspaceProgress(workspace) {
const group = this._workspaceGroups.find(g =>
g.workspace.index() === workspace.index());
return this._getWorkspaceGroupProgress(group);
}

getSnapPoints() {
return this._workspaceGroups.map(g =>
this._getWorkspaceGroupProgress(g));
}

findClosestWorkspace(progress) {
const distances = this.getSnapPoints().map(p =>
Math.abs(p - progress));
const index = distances.indexOf(Math.min(...distances));
return this._workspaceGroups[index].workspace;
}

const { WORKSPACE_SPACING } = GWorkspaceAnimation;
_interpolateProgress(progress, monitorGroup) {
if (this.index === monitorGroup.index)
return progress;

const points1 = monitorGroup.getSnapPoints();
const points2 = this.getSnapPoints();

const upper = points1.indexOf(points1.find(p => p >= progress));
const lower = points1.indexOf(points1.slice().reverse().find(p => p <= progress));

if (points1[upper] === points1[lower])
return points2[upper];

const t = (progress - points1[lower]) / (points1[upper] - points1[lower]);

return points2[lower] + (points2[upper] - points2[lower]) * t;
}

updateSwipeForMonitor(progress, monitorGroup) {
this.progress = this._interpolateProgress(progress, monitorGroup);
}

// The above is a copy of now inaccessible GWorkspaceAnimation.MonitorGroup
// Modifications below.

const MonitorGroup = GObject.registerClass(
class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
_init(monitor, workspaceIndices, movingWindow) {
super._init(monitor, workspaceIndices, movingWindow);
super._init({
clip_to_allocation: true,
style_class: 'workspace-animation',
});

this._monitor = monitor;

const constraint = new Layout.MonitorConstraint({ index: monitor.index });
this.add_constraint(constraint);

this._container = new Clutter.Actor();
this.add_child(this._container);

const stickyGroup = new GWorkspaceAnimation.WorkspaceGroup(null, monitor, movingWindow);
this.add_child(stickyGroup);

this.activeWorkspace = workspaceIndices[0];
this.targetWorkspace = workspaceIndices[workspaceIndices.length - 1];

this._workspaceGroups = [];

const workspaceManager = global.workspace_manager;
const activeWorkspace = workspaceManager.get_active_workspace();

let x = 0;
let y = 0;
let workspaceManager = global.workspace_manager;
this._workspaceGroups = [];

for (const i of workspaceIndices) {
let fromRow = Math.floor(this.activeWorkspace / this.columns);
Expand All @@ -37,10 +120,6 @@ class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
}

const group = new GWorkspaceAnimation.WorkspaceGroup(ws, monitor, movingWindow);
// avoid warnings
group._syncStacking = () => {
};

this._workspaceGroups.push(group);
this._container.add_child(group);
group.set_position(x, y);
Expand All @@ -55,6 +134,8 @@ class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
else if (targetColumn < fromColumn)
x -= this.baseDistanceX;
}

this.progress = this.getWorkspaceProgress(activeWorkspace);
}

get rows() {
Expand Down Expand Up @@ -132,7 +213,7 @@ class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
}
});

class WorkspaceAnimationController extends GWorkspaceAnimation.WorkspaceAnimationController {
var WorkspaceAnimationController = class WorkspaceAnimationController extends GWorkspaceAnimation.WorkspaceAnimationController {
_prepareWorkspaceSwitch(workspaceIndices) {
if (this._switchData)
return;
Expand Down Expand Up @@ -169,3 +250,38 @@ class WorkspaceAnimationController extends GWorkspaceAnimation.WorkspaceAnimatio
Meta.disable_unredirect_for_display(global.display);
}
}

var WorkspaceGroup = class {
constructor() {
this.originalLayout = null;
this._overrideProperties = {
_syncStacking() {
const windowActors = global.get_window_actors().filter(w =>
this._shouldShowWindow(w.meta_window));

let lastRecord;

for (const windowActor of windowActors) {
const record = this._windowRecords.find(r => r.windowActor === windowActor);

if (record && lastRecord) {
this.set_child_above_sibling(record.clone, lastRecord ? lastRecord.clone : this._background);
lastRecord = record;
}
}
},
Comment on lines +258 to +272
Copy link
Owner

@mzur mzur Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ettavolt Could you please explain why this is override necessary? The (record && lastRecord) will never be true. Otherwise I see no difference to the upstream code.

}
}

destroy() {
this.restoreOriginalProperties();
}

overrideOriginalProperties() {
this.originalLayout = Util.overrideProto(GWorkspaceAnimation.WorkspaceGroup, this._overrideProperties);
}

restoreOriginalProperties() {
Util.overrideProto(GWorkspaceAnimation.WorkspaceGroup, this.originalLayout);
}
}
12 changes: 11 additions & 1 deletion [email protected]/workspacePopup/workspaceManagerOverride.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var WorkspaceManagerOverride = class {
'_workspaceAnimation',
'handleWorkspaceScroll',
];

this._overrideWorkspaceGroup();
this._overrideDynamicWorkspaces();
this._overrideKeybindingHandlers();
this._overrideOriginalProperties();
Expand All @@ -45,6 +45,7 @@ var WorkspaceManagerOverride = class {
}

destroy() {
this._restoreWorkspaceGroup();
this._destroyWorkspaceSwitcherPopup();
this._restoreLayout();
this._restoreKeybindingHandlers();
Expand Down Expand Up @@ -283,6 +284,15 @@ var WorkspaceManagerOverride = class {
}
}

_overrideWorkspaceGroup() {
this.overrideWorkspaceGroup = new WorkspaceAnimation.WorkspaceGroup();
this.overrideWorkspaceGroup.overrideOriginalProperties();
}

_restoreWorkspaceGroup() {
this.overrideWorkspaceGroup.destroy();
}

_overrideDynamicWorkspaces() {
this._mutterSettings.set_boolean('dynamic-workspaces', false);
}
Expand Down