Skip to content

Commit 0a6bd59

Browse files
authored
Merge pull request #97 from mzur/3.36_compatibility
Fix overview compatibility with GNOME 3.36 (fixes #96)
2 parents 6658248 + 5531022 commit 0a6bd59

10 files changed

+107
-122
lines changed

[email protected]/BaseWorkspaceSwitcherPopup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const { GLib, GObject} = imports.gi;
22
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup.WorkspaceSwitcherPopup;
3-
const Mainloop = imports.mainloop;
43

54
var BaseWorkspaceSwitcherPopup = GObject.registerClass(
65
class BaseWorkspaceSwitcherPopup extends WorkspaceSwitcherPopup {
@@ -13,12 +12,12 @@ class BaseWorkspaceSwitcherPopup extends WorkspaceSwitcherPopup {
1312
super.display(direction, activeWorkspaceIndex);
1413

1514
if (this._timeoutId !== 0) {
16-
Mainloop.source_remove(this._timeoutId);
15+
GLib.source_remove(this._timeoutId);
1716
this._timeoutId = 0;
1817
}
1918

2019
if (this._popupTimeout > 0) {
21-
this._timeoutId = Mainloop.timeout_add(this._popupTimeout, this._onTimeout.bind(this));
20+
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._popupTimeout, this._onTimeout.bind(this));
2221
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._onTimeout');
2322
}
2423
}

[email protected]/IndicatorWsmatrixPopup.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class IndicatorWsmatrixPopupList extends WorkspaceSwitcherPopupList {
1919
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
2020
let themeNode = this.get_theme_node();
2121

22-
let availHeight = workArea.height;
23-
availHeight -= themeNode.get_vertical_padding();
22+
let availHeight = workArea.height - themeNode.get_vertical_padding();
2423

2524
let height = 0;
2625
let [, childNaturalHeight] = children[0].get_preferred_height(-1);
@@ -45,8 +44,7 @@ class IndicatorWsmatrixPopupList extends WorkspaceSwitcherPopupList {
4544
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
4645
let themeNode = this.get_theme_node();
4746

48-
let availWidth = workArea.width;
49-
availWidth -= themeNode.get_horizontal_padding();
47+
let availWidth = workArea.width - themeNode.get_horizontal_padding();
5048

5149
let width = Math.round(this._childHeight * workArea.width / workArea.height) * this._columns;
5250

@@ -56,7 +54,7 @@ class IndicatorWsmatrixPopupList extends WorkspaceSwitcherPopupList {
5654

5755
this._childWidth = (width - spacing) / this._columns;
5856

59-
return themeNode.adjust_preferred_width(width, width);
57+
return [width, width];
6058
}
6159

6260
vfunc_allocate(box, flags) {
@@ -113,20 +111,13 @@ class IndicatorWsmatrixPopup extends BaseWorkspaceSwitcherPopup {
113111
this._container.x = workArea.x + Math.floor((workArea.width - containerNatWidth) / 2);
114112
this._container.y = workArea.y + Math.floor((workArea.height - containerNatHeight) / 2);
115113

116-
let indicators = this._list.get_children();
117-
for (let i = 0; i < indicators.length; i++) {
118-
if (this.showWorkspaceNames) {
119-
let workspaceName = Meta.prefs_get_workspace_name(i);
120-
indicators[i].child = new St.Label({
121-
text: workspaceName,
114+
if (this.showWorkspaceNames) {
115+
this._list.get_children().forEach(function (indicator, index) {
116+
indicator.child = new St.Label({
117+
text: Meta.prefs_get_workspace_name(index),
122118
style_class: "ws-switcher-label"
123119
});
124-
}
125-
if (i === this._activeWorkspaceIndex && (this._direction == Meta.MotionDirection.UP || this._direction == Meta.MotionDirection.LEFT)) {
126-
indicators[i].style_class = 'wsmatrix ws-switcher-active-up';
127-
} else if (i === this._activeWorkspaceIndex) {
128-
indicators[i].style_class = 'wsmatrix ws-switcher-active-down';
129-
}
120+
});
130121
}
131122
}
132123
});

[email protected]/OverviewOverride.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ var OverviewOverride = class {
7575

7676
_activateOverride() {
7777
this._overrideActive = true;
78-
let workspacesDisplay = Main.overview._controls.viewSelector._workspacesDisplay;
78+
let workspacesDisplay = Main.overview._overview._controls.viewSelector._workspacesDisplay;
7979
this._workspacesDisplayOverride = new WorkspacesDisplayOverride(workspacesDisplay);
80-
let thumbnailsBox = Main.overview._controls._thumbnailsBox;
80+
let thumbnailsBox = Main.overview._overview._controls._thumbnailsBox;
8181
this._thumbnailsBoxOverride = new ThumbnailsBoxOverride(thumbnailsBox, this.rows, this.columns);
8282
this._workspacesViewOverride = new WorkspacesViewOverride(this.settings);
8383
}

[email protected]/ThumbnailWsmatrixPopup.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class ThumbnailWsmatrixPopupList extends WorkspaceSwitcherPopupList {
2121
let children = this.get_children();
2222
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
2323
let themeNode = this.get_theme_node();
24+
let spacing = themeNode.get_length('spacing');
2425

25-
let availHeight = workArea.height;
26-
availHeight -= themeNode.get_vertical_padding();
26+
let availHeight = workArea.height - themeNode.get_vertical_padding();
2727

2828
let height = this._rows * this._scale * children[0].get_height();
29-
let spacing = this._itemSpacing * (this._rows - 1);
29+
let totalSpacing = spacing * (this._rows - 1);
3030

31-
height += spacing;
31+
height += totalSpacing;
3232
height = Math.round(Math.min(height, availHeight));
3333

34-
this._childHeight = Math.round((height - spacing) / this._rows);
34+
this._childHeight = Math.round((height - totalSpacing) / this._rows);
3535

3636
return themeNode.adjust_preferred_height(height, height);
3737
}
@@ -40,37 +40,44 @@ class ThumbnailWsmatrixPopupList extends WorkspaceSwitcherPopupList {
4040
let children = this.get_children();
4141
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
4242
let themeNode = this.get_theme_node();
43+
let spacing = themeNode.get_length('spacing');
4344

44-
let availWidth = workArea.width;
45-
availWidth -= themeNode.get_horizontal_padding();
45+
let availWidth = workArea.width - themeNode.get_horizontal_padding();
4646

4747
let width = this._columns * this._scale * children[0].get_width();
48-
let spacing = this._itemSpacing * (this._columns - 1);
48+
let totalSpacing = spacing * (this._columns - 1);
4949

50-
width += spacing;
50+
width += totalSpacing;
5151
width = Math.round(Math.min(width, availWidth));
5252

53-
this._childWidth = Math.round((width - spacing) / this._columns);
53+
this._childWidth = Math.round((width - totalSpacing) / this._columns);
5454

55-
return themeNode.adjust_preferred_height(width, width);
55+
return [width, width];
5656
}
5757

5858
vfunc_allocate(box, flags) {
5959
this.set_allocation(box, flags);
6060

6161
let themeNode = this.get_theme_node();
6262
box = themeNode.get_content_box(box);
63+
let spacing = themeNode.get_length('spacing');
6364

6465
let children = this.get_children();
6566
let childBox = new Clutter.ActorBox();
6667

6768
let row = 0;
6869
let column = 0;
69-
let itemWidth = this._childWidth + this._itemSpacing;
70-
let itemHeight = this._childHeight + this._itemSpacing;
71-
let indicatorOffset = Math.round(this._itemSpacing / 2);
70+
let itemWidth = this._childWidth + spacing;
71+
let itemHeight = this._childHeight + spacing;
7272
let indicator = children.pop();
7373

74+
let indicatorThemeNode = indicator.get_theme_node();
75+
76+
let indicatorTopFullBorder = indicatorThemeNode.get_padding(St.Side.TOP) + indicatorThemeNode.get_border_width(St.Side.TOP);
77+
let indicatorBottomFullBorder = indicatorThemeNode.get_padding(St.Side.BOTTOM) + indicatorThemeNode.get_border_width(St.Side.BOTTOM);
78+
let indicatorLeftFullBorder = indicatorThemeNode.get_padding(St.Side.LEFT) + indicatorThemeNode.get_border_width(St.Side.LEFT);
79+
let indicatorRightFullBorder = indicatorThemeNode.get_padding(St.Side.RIGHT) + indicatorThemeNode.get_border_width(St.Side.RIGHT);
80+
7481
for (let i = 0; i < children.length; i++) {
7582
row = Math.floor(i / this._columns);
7683
column = i % this._columns;
@@ -82,10 +89,10 @@ class ThumbnailWsmatrixPopupList extends WorkspaceSwitcherPopupList {
8289
children[i].allocate(childBox, flags);
8390

8491
if (i === this._activeWorkspaceIndex) {
85-
childBox.x1 -= indicatorOffset;
86-
childBox.x2 = childBox.x1 + this._childWidth + indicatorOffset * 2;
87-
childBox.y1 -= indicatorOffset;
88-
childBox.y2 = childBox.y1 + this._childHeight + indicatorOffset * 2;
92+
childBox.x2 = childBox.x1 + this._childWidth + indicatorRightFullBorder;
93+
childBox.x1 -= indicatorLeftFullBorder;
94+
childBox.y2 = childBox.y1 + this._childHeight + indicatorBottomFullBorder;
95+
childBox.y1 -= indicatorTopFullBorder;
8996
indicator.allocate(childBox, flags);
9097
}
9198
}

[email protected]/ThumbnailsBoxOverride.js

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var ThumbnailsBoxOverride = class {
1414
this.thumbnailsBox = thumbnailsBox;
1515
this.overrideProperties = [
1616
'_activateThumbnailAtPoint',
17-
'_activeWorkspaceChanged',
1817
'allocate',
1918
'handleDragOver',
2019
'get_preferred_height',
@@ -87,7 +86,7 @@ var ThumbnailsBoxOverride = class {
8786
// Overriding the switch to workspace method
8887
// triggered on clicking a workspace thumbnail in the thumbnailbox of the overview
8988
_activateThumbnailAtPoint(stageX, stageY, time) {
90-
let [r, x, y] = this.transform_stage_point(stageX, stageY);
89+
let [, x, y] = this.transform_stage_point(stageX, stageY);
9190

9291
let thumbnail = this._thumbnails.find(t => {
9392
let [w, h] = t.get_transformed_size();
@@ -99,31 +98,6 @@ var ThumbnailsBoxOverride = class {
9998
}
10099
}
101100

102-
// Overriding the Tweener animation to consider both vertical and horizontal changes
103-
// the original method only animates vertically
104-
_activeWorkspaceChanged(wm, from, to, direction) {
105-
let workspaceManager = global.workspace_manager;
106-
let activeWorkspace = workspaceManager.get_active_workspace();
107-
let thumbnail = this._thumbnails.find(t => t.metaWorkspace == activeWorkspace);
108-
let [thumbX, thumbY] = thumbnail.get_position();
109-
110-
this._animatingIndicator = true;
111-
112-
//todo: this code should animate x & y, but for some reason it is not
113-
this._indicator.ease({
114-
thumbX,
115-
thumbY,
116-
duration: WorkspacesView.WORKSPACE_SWITCH_TIME,
117-
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
118-
onComplete: () => {
119-
this._animatingIndicator = false;
120-
this.indicator_x = thumbX;
121-
this.indicator_y = thumbY;
122-
this._queueUpdateStates();
123-
}
124-
});
125-
}
126-
127101
// It is helpful to be able to control the height
128102
// however, this method is not being called for some reason
129103
get_preferred_height(forWidth) {
@@ -147,8 +121,8 @@ var ThumbnailsBoxOverride = class {
147121
let totalSpacingX = (this.getColumns() - 1) * spacing;
148122
let totalSpacingY = (this.getRows() - 1) * spacing;
149123

150-
let availY = forHeight - totalSpacingY;
151-
let scale = availY < 0 ? MAX_THUMBNAIL_SCALE : (availY / this.getRows()) / this._porthole.height;
124+
let availY = Math.max(0, forHeight - totalSpacingY);
125+
let scale = (availY / this.getRows()) / this._porthole.height;
152126
scale = Math.min(scale, MAX_THUMBNAIL_SCALE);
153127

154128
let width = Math.round(totalSpacingX + this.getColumns() * this._porthole.width * scale);
@@ -168,7 +142,7 @@ var ThumbnailsBoxOverride = class {
168142
allocate(box, flags) {
169143
this._overrideProperties.allocate(box, flags);
170144

171-
let rtl = (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL);
145+
let rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
172146

173147
if (this._thumbnails.length == 0) // not visible
174148
return;
@@ -315,30 +289,33 @@ var ThumbnailsBoxOverride = class {
315289

316290
// Handle dragging a window into a workspace
317291
handleDragOver(source, actor, x, y, time) {
318-
if (!source.realWindow && !source.shellWorkspaceLaunch && source != Main.xdndHandler)
292+
if (!source.realWindow &&
293+
(!source.app || !source.app.can_open_new_window()) &&
294+
(source.app || !source.shellWorkspaceLaunch) &&
295+
source != Main.xdndHandler)
319296
return DND.DragMotionResult.CONTINUE;
320297

321298
let canCreateWorkspaces = Meta.prefs_get_dynamic_workspaces();
322299
let spacing = this.get_theme_node().get_length('spacing');
323300

324301
this._dropWorkspace = -1;
325302
let placeholderPos = -1;
326-
let targetBaseY;
303+
let targetBase;
327304
if (this._dropPlaceholderPos == 0)
328-
targetBaseY = this._dropPlaceholder.y;
305+
targetBase = this._dropPlaceholder.y;
329306
else
330-
targetBaseY = this._thumbnails[0].y;
331-
let targetTop = targetBaseY - spacing - WorkspaceThumbnail.WORKSPACE_CUT_SIZE;
307+
targetBase = this._thumbnails[0].y;
308+
let targetTop = targetBase - spacing - WorkspaceThumbnail.WORKSPACE_CUT_SIZE;
332309

333310
let length = this._thumbnails.length;
334311
for (let i = 0; i < length; i++) {
335312
// Allow the reorder target to have a 10px "cut" into
336313
// each side of the thumbnail, to make dragging onto the
337314
// placeholder easier
338315
let [w, h] = this._thumbnails[i].get_transformed_size();
339-
let targetBottom = targetBaseY + WorkspaceThumbnail.WORKSPACE_CUT_SIZE;
340-
let nextTargetBaseY = targetBaseY + h + spacing;
341-
let nextTargetTop = nextTargetBaseY - spacing - ((i == length - 1) ? 0 : WorkspaceThumbnail.WORKSPACE_CUT_SIZE);
316+
let targetBottom = targetBase + WorkspaceThumbnail.WORKSPACE_CUT_SIZE;
317+
let nextTargetBase = targetBase + h + spacing;
318+
let nextTargetTop = nextTargetBase - spacing - ((i == length - 1) ? 0 : WorkspaceThumbnail.WORKSPACE_CUT_SIZE);
342319

343320
// Expand the target to include the placeholder, if it exists.
344321
if (i == this._dropPlaceholderPos)
@@ -354,7 +331,7 @@ var ThumbnailsBoxOverride = class {
354331
break
355332
}
356333

357-
targetBaseY = nextTargetBaseY;
334+
targetBase = nextTargetBase;
358335
targetTop = nextTargetTop;
359336
}
360337

@@ -364,7 +341,7 @@ var ThumbnailsBoxOverride = class {
364341
}
365342

366343
if (this._dropWorkspace != -1)
367-
return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, time);
344+
return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, actor, time);
368345
else if (this._dropPlaceholderPos != -1)
369346
return source.realWindow ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.COPY_DROP;
370347
else

[email protected]/WmOverride.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ var WmOverride = class {
4444

4545
destroy() {
4646
this._destroyWorkspaceSwitcherPopup();
47-
this._disconnectSettings();
48-
this._restoreKeybindingHandlers();
4947
this._restoreLayout();
48+
this._restoreKeybindingHandlers();
5049
this._restoreDynamicWorkspaces();
50+
this._disconnectSettings();
5151
this._notify();
5252
this._removeKeybindings();
5353
this._disconnectOverview();
@@ -254,8 +254,8 @@ var WmOverride = class {
254254
_restoreLayout() {
255255
this.wsManager.override_workspace_layout(
256256
DisplayWrapper.getDisplayCorner().TOPLEFT, // workspace 0
257-
true, // true == lay out in columns. false == lay out in rows
258-
this.rows * this.columns,
257+
false, // true == lay out in columns. false == lay out in rows
258+
-1,
259259
1
260260
);
261261
}

0 commit comments

Comments
 (0)