Skip to content

Commit 3748703

Browse files
authored
Merge pull request #218 from mzur/gnome-42
GNOME 42 support
2 parents 2afeac4 + 6683c38 commit 3748703

File tree

8 files changed

+149
-62
lines changed

8 files changed

+149
-62
lines changed

[email protected]/metadata.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"shell-version": [
3-
"40",
4-
"41"
3+
"42"
54
],
65
"uuid": "[email protected]",
76
"url": "https://github.com/mzur/gnome-shell-wsmatrix",

[email protected]/overview/controlsManagerLayout.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@ const ExtensionUtils = imports.misc.extensionUtils;
22
const Self = ExtensionUtils.getCurrentExtension();
33
const Util = Self.imports.util;
44
const OverviewControls = imports.ui.overviewControls;
5+
const { ControlsState } = OverviewControls;
56

6-
const { SMALL_WORKSPACE_RATIO } = OverviewControls;
7+
//const { SMALL_WORKSPACE_RATIO } = OverviewControls;
8+
const SMALL_WORKSPACE_RATIO = 0.15;
79

810
var ControlsManagerLayout = class {
911
constructor() {
1012
this.originalLayout = null;
1113
this._overrideProperties = {
12-
_computeWorkspacesBoxForState(state, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
13-
const { ControlsState } = OverviewControls;
14-
const workspaceBox = workAreaBox.copy();
15-
const [startX, startY] = workAreaBox.get_origin();
14+
_computeWorkspacesBoxForState(state, box, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
15+
const workspaceBox = box.copy();
1616
const [width, height] = workspaceBox.get_size();
17+
const { y1: startY } = workAreaBox;
1718
const {spacing} = this;
1819
const {expandFraction} = this._workspacesThumbnails;
1920
let workspaceManager = global.workspace_manager;
2021
let rows = workspaceManager.layout_rows;
2122

2223
switch (state) {
2324
case ControlsState.HIDDEN:
25+
workspaceBox.set_origin(...workAreaBox.get_origin());
26+
workspaceBox.set_size(...workAreaBox.get_size());
2427
break;
2528
case ControlsState.WINDOW_PICKER:
26-
workspaceBox.set_origin(startX,
29+
workspaceBox.set_origin(0,
2730
startY + searchHeight + spacing +
2831
thumbnailsHeight * rows + spacing * expandFraction);
2932
workspaceBox.set_size(width,
@@ -33,7 +36,7 @@ var ControlsManagerLayout = class {
3336
thumbnailsHeight * rows - spacing * expandFraction);
3437
break;
3538
case ControlsState.APP_GRID:
36-
workspaceBox.set_origin(startX, startY + searchHeight + spacing);
39+
workspaceBox.set_origin(0, startY + searchHeight + spacing);
3740
workspaceBox.set_size(
3841
width,
3942
Math.round(height * rows * SMALL_WORKSPACE_RATIO));

[email protected]/overview/overviewManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ var OverviewManager = class {
4242
this._thumbnailsBoxOverride.overrideOriginalProperties();
4343
this._workspacesViewOverride.overrideOriginalProperties();
4444
this._controlsManagerLayoutOverride.overrideOriginalProperties();
45-
this._secondaryMonitorDisplayOverride.overrideOriginalProperties();
45+
// Disabled until override objects can be imported again
46+
// see: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2266
47+
// this._secondaryMonitorDisplayOverride.overrideOriginalProperties();
4648
}
4749

4850
restore() {
4951
this._thumbnailsBoxOverride.restoreOriginalProperties();
5052
this._workspacesViewOverride.restoreOriginalProperties();
5153
this._controlsManagerLayoutOverride.restoreOriginalProperties();
52-
this._secondaryMonitorDisplayOverride.restoreOriginalProperties();
54+
// Disabled (see above).
55+
// this._secondaryMonitorDisplayOverride.restoreOriginalProperties();
5356
}
5457

5558
destroy() {
0 Bytes
Binary file not shown.

[email protected]/schemas/org.gnome.shell.extensions.wsmatrix.gschema.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
</enum>
88
<schema id="org.gnome.shell.extensions.wsmatrix-settings" path="/org/gnome/shell/extensions/wsmatrix/">
99
<key type="i" name="num-columns">
10-
<default>3</default>
10+
<default>2</default>
1111
<range min="1" max="36"/>
1212
<summary>Number of columns of workspaces</summary>
1313
</key>
1414
<key type="i" name="num-rows">
15-
<default>3</default>
15+
<default>2</default>
1616
<range min="1" max="36"/>
1717
<summary>Number of rows of workspaces</summary>
1818
</key>
1919
<key type="i" name="popup-timeout">
20-
<default>10</default>
20+
<default>500</default>
2121
<range min="0" max="5000"/>
2222
<summary>Time to show the popup (ms)</summary>
2323
</key>
@@ -35,7 +35,7 @@
3535
<summary>Whether to allow hovering on workspaces in popup or not</summary>
3636
</key>
3737
<key type="b" name="show-workspace-names">
38-
<default>true</default>
38+
<default>false</default>
3939
<summary>Whether to show workspace names or not</summary>
4040
</key>
4141
<key name="wraparound-mode" enum="org.gnome.shell.extensions.wsmatrix.wraparoundMode">

[email protected]/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Gio = imports.gi.Gio;
44
const Self = imports.misc.extensionUtils.getCurrentExtension();
55

66
function hookVfunc(proto, symbol, func) {
7-
proto[Gi.hook_up_vfunc_symbol](symbol, func);
7+
proto[Gi.hook_up_vfunc_symbol].call(proto[Gi.gobject_prototype_symbol], symbol, func);
88
}
99

1010
function overrideProto(proto, overrides) {

[email protected]/workspacePopup/workspaceAnimation.js

Lines changed: 93 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,105 @@
1-
const {GObject, Meta, St} = imports.gi;
1+
const {Clutter, GObject, Meta, St} = imports.gi;
22

33
const Main = imports.ui.main;
44
const GWorkspaceAnimation = imports.ui.workspaceAnimation;
5+
const Layout = imports.ui.layout;
6+
const ExtensionUtils = imports.misc.extensionUtils;
7+
const Self = ExtensionUtils.getCurrentExtension();
8+
const Util = Self.imports.util;
9+
// const {WORKSPACE_SPACING} = GWorkspaceAnimation;
10+
const WORKSPACE_SPACING = 100;
11+
12+
const MonitorGroup = GObject.registerClass({
13+
Properties: {
14+
'progress': GObject.ParamSpec.double(
15+
'progress', 'progress', 'progress',
16+
GObject.ParamFlags.READWRITE,
17+
-Infinity, Infinity, 0),
18+
},
19+
}, class MonitorGroup extends St.Widget {
20+
get baseDistance() {
21+
const spacing = WORKSPACE_SPACING * St.ThemeContext.get_for_stage(global.stage).scale_factor;
22+
23+
if (global.workspace_manager.layout_rows === -1)
24+
return this._monitor.height + spacing;
25+
else
26+
return this._monitor.width + spacing;
27+
}
28+
29+
get index() {
30+
return this._monitor.index;
31+
}
32+
33+
getWorkspaceProgress(workspace) {
34+
const group = this._workspaceGroups.find(g =>
35+
g.workspace.index() === workspace.index());
36+
return this._getWorkspaceGroupProgress(group);
37+
}
38+
39+
getSnapPoints() {
40+
return this._workspaceGroups.map(g =>
41+
this._getWorkspaceGroupProgress(g));
42+
}
43+
44+
findClosestWorkspace(progress) {
45+
const distances = this.getSnapPoints().map(p =>
46+
Math.abs(p - progress));
47+
const index = distances.indexOf(Math.min(...distances));
48+
return this._workspaceGroups[index].workspace;
49+
}
50+
51+
_interpolateProgress(progress, monitorGroup) {
52+
if (this.index === monitorGroup.index)
53+
return progress;
554

6-
const { WORKSPACE_SPACING } = GWorkspaceAnimation;
55+
const points1 = monitorGroup.getSnapPoints();
56+
const points2 = this.getSnapPoints();
57+
58+
const upper = points1.indexOf(points1.find(p => p >= progress));
59+
const lower = points1.indexOf(points1.slice().reverse().find(p => p <= progress));
60+
61+
if (points1[upper] === points1[lower])
62+
return points2[upper];
63+
64+
const t = (progress - points1[lower]) / (points1[upper] - points1[lower]);
65+
66+
return points2[lower] + (points2[upper] - points2[lower]) * t;
67+
}
68+
69+
updateSwipeForMonitor(progress, monitorGroup) {
70+
this.progress = this._interpolateProgress(progress, monitorGroup);
71+
}
72+
73+
// The above is a copy of now inaccessible GWorkspaceAnimation.MonitorGroup
74+
// Modifications below.
775

8-
const MonitorGroup = GObject.registerClass(
9-
class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
1076
_init(monitor, workspaceIndices, movingWindow) {
11-
super._init(monitor, workspaceIndices, movingWindow);
77+
super._init({
78+
clip_to_allocation: true,
79+
style_class: 'workspace-animation',
80+
});
81+
82+
this._monitor = monitor;
83+
84+
const constraint = new Layout.MonitorConstraint({ index: monitor.index });
85+
this.add_constraint(constraint);
86+
87+
this._container = new Clutter.Actor();
88+
this.add_child(this._container);
89+
90+
const stickyGroup = new GWorkspaceAnimation.WorkspaceGroup(null, monitor, movingWindow);
91+
this.add_child(stickyGroup);
1292

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

96+
this._workspaceGroups = [];
97+
98+
const workspaceManager = global.workspace_manager;
99+
const activeWorkspace = workspaceManager.get_active_workspace();
100+
16101
let x = 0;
17102
let y = 0;
18-
let workspaceManager = global.workspace_manager;
19-
this._workspaceGroups = [];
20103

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

39122
const group = new GWorkspaceAnimation.WorkspaceGroup(ws, monitor, movingWindow);
40-
// avoid warnings
41-
group._syncStacking = () => {
42-
};
43-
44123
this._workspaceGroups.push(group);
45124
this._container.add_child(group);
46125
group.set_position(x, y);
@@ -55,6 +134,8 @@ class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
55134
else if (targetColumn < fromColumn)
56135
x -= this.baseDistanceX;
57136
}
137+
138+
this.progress = this.getWorkspaceProgress(activeWorkspace);
58139
}
59140

60141
get rows() {
@@ -132,7 +213,7 @@ class MonitorGroup extends GWorkspaceAnimation.MonitorGroup {
132213
}
133214
});
134215

135-
class WorkspaceAnimationController extends GWorkspaceAnimation.WorkspaceAnimationController {
216+
var WorkspaceAnimationController = class WorkspaceAnimationController extends GWorkspaceAnimation.WorkspaceAnimationController {
136217
_prepareWorkspaceSwitch(workspaceIndices) {
137218
if (this._switchData)
138219
return;

[email protected]/workspacePopup/workspaceManagerOverride.js

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var WorkspaceManagerOverride = class {
3131
'_workspaceAnimation',
3232
'handleWorkspaceScroll',
3333
];
34-
3534
this._overrideDynamicWorkspaces();
3635
this._overrideKeybindingHandlers();
3736
this._overrideOriginalProperties();
@@ -422,46 +421,48 @@ var WorkspaceManagerOverride = class {
422421
}
423422

424423
_showWorkspaceSwitcherPopup(toggle) {
424+
if (Main.overview.visible) {
425+
return;
426+
}
427+
425428
if (toggle) {
426429
this._addWorkspaceOverviewKeybindings();
427430
}
428431

429-
if (!Main.overview.visible) {
430-
this.monitors.forEach((monitor) => {
431-
let monitorIndex = monitor.index;
432-
433-
if (!this.wm._wsPopupList[monitorIndex]) {
434-
this.wm._workspaceTracker.blockUpdates();
435-
this.wm._wsPopupList[monitorIndex] = this._createNewPopup({
436-
monitorIndex: monitorIndex,
437-
toggle: toggle,
438-
});
439-
this.wm._wsPopupList[monitorIndex].connect('destroy', () => {
440-
this.wm._workspaceTracker.unblockUpdates();
441-
this.wm._wsPopupList[monitorIndex] = null;
442-
if (monitorIndex === Main.layoutManager.primaryIndex) {
443-
this.wm._workspaceSwitcherPopup = null;
444-
this.wm._isWorkspacePrepended = false;
445-
if (toggle) {
446-
this._removeWorkspaceOverviewKeybindings();
447-
}
448-
}
449-
});
450-
451-
let event = Clutter.get_current_event();
452-
let modifiers = event ? event.get_state() & Clutter.ModifierType.MODIFIER_MASK : 0;
453-
this.wm._wsPopupList[monitorIndex].showToggle(false, null, modifiers, toggle);
454-
if (monitorIndex === Main.layoutManager.primaryIndex) {
455-
this.wm._workspaceSwitcherPopup = this.wm._wsPopupList[monitorIndex];
456-
}
457-
} else {
458-
// reset of popup
432+
this.monitors.forEach((monitor) => {
433+
let monitorIndex = monitor.index;
434+
435+
if (!this.wm._wsPopupList[monitorIndex]) {
436+
this.wm._workspaceTracker.blockUpdates();
437+
this.wm._wsPopupList[monitorIndex] = this._createNewPopup({
438+
monitorIndex: monitorIndex,
439+
toggle: toggle,
440+
});
441+
this.wm._wsPopupList[monitorIndex].connect('destroy', () => {
442+
this.wm._workspaceTracker.unblockUpdates();
443+
this.wm._wsPopupList[monitorIndex] = null;
459444
if (monitorIndex === Main.layoutManager.primaryIndex) {
460-
this.wm._wsPopupList[monitorIndex].resetTimeout();
445+
this.wm._workspaceSwitcherPopup = null;
446+
this.wm._isWorkspacePrepended = false;
447+
if (toggle) {
448+
this._removeWorkspaceOverviewKeybindings();
449+
}
461450
}
451+
});
452+
453+
let event = Clutter.get_current_event();
454+
let modifiers = event ? event.get_state() & Clutter.ModifierType.MODIFIER_MASK : 0;
455+
this.wm._wsPopupList[monitorIndex].showToggle(false, null, modifiers, toggle);
456+
if (monitorIndex === Main.layoutManager.primaryIndex) {
457+
this.wm._workspaceSwitcherPopup = this.wm._wsPopupList[monitorIndex];
462458
}
463-
});
464-
}
459+
} else {
460+
// reset of popup
461+
if (monitorIndex === Main.layoutManager.primaryIndex) {
462+
this.wm._wsPopupList[monitorIndex].resetTimeout();
463+
}
464+
}
465+
});
465466
}
466467

467468
_destroyWorkspaceSwitcherPopup() {

0 commit comments

Comments
 (0)