Skip to content

Commit e715720

Browse files
committed
Make extension compatible with GNOME 3.32
1 parent 48b1f91 commit e715720

File tree

3 files changed

+82
-54
lines changed

3 files changed

+82
-54
lines changed

[email protected]/WmOverride.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const WsMatrix = imports.misc.extensionUtils.getCurrentExtension();
2-
const WorkspaceSwitcherPopup = WsMatrix.imports.WorkspaceSwitcherPopup;
2+
const WsmatrixPopup = WsMatrix.imports.WorkspaceSwitcherPopup.WsmatrixPopup;
33
const DisplayWrapper = WsMatrix.imports.DisplayWrapper.DisplayWrapper;
44
const Shell = imports.gi.Shell;
55
const Meta = imports.gi.Meta;
@@ -206,7 +206,7 @@ var WmOverride = class {
206206
if (!Main.overview.visible) {
207207
if (this.wm._workspaceSwitcherPopup == null) {
208208
this.wm._workspaceTracker.blockUpdates();
209-
this.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup(this.rows, this.columns, this.scale);
209+
this.wm._workspaceSwitcherPopup = new WsmatrixPopup(this.rows, this.columns, this.scale);
210210
this.wm._workspaceSwitcherPopup.connect('destroy', () => {
211211
this.wm._workspaceTracker.unblockUpdates();
212212
this.wm._workspaceSwitcherPopup = null;
Lines changed: 79 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,66 @@
1+
const { Clutter, GObject, Meta, St } = imports.gi;
12
const WsMatrix = imports.misc.extensionUtils.getCurrentExtension();
23
const DisplayWrapper = WsMatrix.imports.DisplayWrapper.DisplayWrapper;
3-
const DefaultWorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
4+
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup.WorkspaceSwitcherPopup;
5+
const WorkspaceSwitcherPopupList = imports.ui.workspaceSwitcherPopup.WorkspaceSwitcherPopupList;
46
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
5-
const Lang = imports.lang;
6-
const Clutter = imports.gi.Clutter;
7-
const St = imports.gi.St;
87
const Main = imports.ui.main;
9-
const Meta = imports.gi.Meta;
10-
11-
var WorkspaceSwitcherPopup = Lang.Class({
12-
Name: 'WsMatrixWorkspaceSwitcherPopup',
13-
Extends: DefaultWorkspaceSwitcherPopup.WorkspaceSwitcherPopup,
14-
15-
_init: function (rows, columns, scale) {
16-
// Set rows and columns before calling parent().
17-
this.rows = rows;
18-
this.columns = columns;
19-
this.scale = scale;
20-
this.wsManager = DisplayWrapper.getWorkspaceManager();
21-
this.parent();
22-
},
23-
24-
_getPreferredHeight(actor, forWidth, alloc) {
25-
let children = this._list.get_children();
8+
9+
var WsmatrixPopupList = GObject.registerClass(
10+
class WsmatrixPopupList extends WorkspaceSwitcherPopupList {
11+
_init(rows, columns, scale) {
12+
super._init();
13+
this._rows = rows;
14+
this._columns = columns;
15+
this._scale = scale;
16+
this._activeWorkspaceIndex = 0;
17+
}
18+
19+
vfunc_get_preferred_height(forWidth) {
20+
let children = this.get_children();
2621
let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
22+
let themeNode = this.get_theme_node();
2723

2824
let availHeight = workArea.height;
29-
availHeight -= this.actor.get_theme_node().get_vertical_padding();
30-
availHeight -= this._container.get_theme_node().get_vertical_padding();
31-
availHeight -= this._list.get_theme_node().get_vertical_padding();
25+
availHeight -= themeNode.get_vertical_padding();
3226

33-
let height = this.rows * this.scale * children[0].get_height();
34-
let spacing = this._itemSpacing * (this.rows - 1);
27+
let height = this._rows * this._scale * children[0].get_height();
28+
let spacing = this._itemSpacing * (this._rows - 1);
3529

3630
height += spacing;
3731
height = Math.round(Math.min(height, availHeight));
3832

39-
this._childHeight = Math.round((height - spacing) / this.rows);
33+
this._childHeight = Math.round((height - spacing) / this._rows);
4034

41-
alloc.min_size = height;
42-
alloc.natural_size = height;
43-
},
35+
return themeNode.adjust_preferred_height(height, height);
36+
}
4437

45-
_getPreferredWidth(actor, forHeight, alloc) {
46-
let children = this._list.get_children();
38+
vfunc_get_preferred_width(forHeight) {
39+
let children = this.get_children();
4740
let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
41+
let themeNode = this.get_theme_node();
4842

4943
let availWidth = workArea.width;
50-
availWidth -= this.actor.get_theme_node().get_horizontal_padding();
51-
availWidth -= this._container.get_theme_node().get_horizontal_padding();
52-
availWidth -= this._list.get_theme_node().get_horizontal_padding();
44+
availWidth -= themeNode.get_horizontal_padding();
5345

54-
let width = this.columns * this.scale * children[0].get_width();
55-
let spacing = this._itemSpacing * (this.columns - 1);
46+
let width = this._columns * this._scale * children[0].get_width();
47+
let spacing = this._itemSpacing * (this._columns - 1);
5648

5749
width += spacing;
5850
width = Math.round(Math.min(width, availWidth));
5951

60-
this._childWidth = Math.round((width - spacing) / this.columns);
52+
this._childWidth = Math.round((width - spacing) / this._columns);
53+
54+
return themeNode.adjust_preferred_height(width, width);
55+
}
56+
57+
vfunc_allocate(box, flags) {
58+
this.set_allocation(box, flags);
6159

62-
alloc.min_size = width;
63-
alloc.natural_size = width;
64-
},
60+
let themeNode = this.get_theme_node();
61+
box = themeNode.get_content_box(box);
6562

66-
_allocate(actor, box, flags) {
67-
let children = this._list.get_children();
63+
let children = this.get_children();
6864
let childBox = new Clutter.ActorBox();
6965

7066
let row = 0;
@@ -75,8 +71,8 @@ var WorkspaceSwitcherPopup = Lang.Class({
7571
let indicator = children.pop();
7672

7773
for (let i = 0; i < children.length; i++) {
78-
row = Math.floor(i / this.columns);
79-
column = i % this.columns;
74+
row = Math.floor(i / this._columns);
75+
column = i % this._columns;
8076

8177
childBox.x1 = Math.round(box.x1 + itemWidth * column);
8278
childBox.x2 = childBox.x1 + children[i].get_width();
@@ -92,16 +88,48 @@ var WorkspaceSwitcherPopup = Lang.Class({
9288
indicator.allocate(childBox, flags);
9389
}
9490
}
95-
},
91+
}
92+
93+
getChildWidth() {
94+
return this._childWidth;
95+
}
96+
97+
getChildHeight() {
98+
return this._childHeight;
99+
}
100+
101+
setActiveWorkspaceIndex(index) {
102+
this._activeWorkspaceIndex = index;
103+
}
104+
});
105+
106+
var WsmatrixPopup = GObject.registerClass(
107+
class WsmatrixPopup extends WorkspaceSwitcherPopup {
108+
_init(rows, columns, scale) {
109+
super._init();
110+
this._workspaceManager = DisplayWrapper.getWorkspaceManager();
111+
let oldList = this._list;
112+
this._list = new WsmatrixPopupList(rows, columns, scale);
113+
this._container.replace_child(oldList, this._list);
114+
this._redisplay();
115+
this.hide();
116+
}
96117

97118
_redisplay() {
119+
if (!(this._list instanceof WsmatrixPopupList)) {
120+
return;
121+
}
122+
98123
this._list.destroy_all_children();
124+
if (this._activeWorkspaceIndex !== undefined) {
125+
this._list.setActiveWorkspaceIndex(this._activeWorkspaceIndex);
126+
}
99127

100-
for (let i = 0; i < this.wsManager.n_workspaces; i++) {
101-
let workspace = this.wsManager.get_workspace_by_index(i);
128+
for (let i = 0; i < this._workspaceManager.n_workspaces; i++) {
129+
let workspace = this._workspaceManager.get_workspace_by_index(i);
102130
let thumbnail = new WorkspaceThumbnail.WorkspaceThumbnail(workspace);
103-
let hScale = this._childWidth / thumbnail.actor.get_width();
104-
let vScale = this._childHeight / thumbnail.actor.get_height();
131+
let hScale = this._list.getChildWidth() / thumbnail.actor.get_width();
132+
let vScale = this._list.getChildHeight() / thumbnail.actor.get_height();
105133
thumbnail.actor.set_scale(hScale, vScale);
106134
this._list.add_actor(thumbnail.actor);
107135
}
@@ -114,5 +142,5 @@ var WorkspaceSwitcherPopup = Lang.Class({
114142
let [containerMinWidth, containerNatWidth] = this._container.get_preferred_width(containerNatHeight);
115143
this._container.x = workArea.x + Math.floor((workArea.width - containerNatWidth) / 2);
116144
this._container.y = workArea.y + Math.floor((workArea.height - containerNatHeight) / 2);
117-
},
145+
}
118146
});

[email protected]/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{
3-
"shell-version": ["3.28", "3.30"],
3+
"shell-version": ["3.32"],
44
"uuid": "[email protected]",
55
"url": "https://github.com/mzur/gnome-shell-wsmatrix",
66
"settings-schema": "org.gnome.shell.extensions.wsmatrix",

0 commit comments

Comments
 (0)