[gnome-shell-extensions] native-window-placement: Adjust to gnome-shell changes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] native-window-placement: Adjust to gnome-shell changes
- Date: Tue, 7 Jul 2020 16:46:04 +0000 (UTC)
commit eff625fcb811f2b71b3598006ac5b6e22c74e386
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Jul 7 16:34:34 2020 +0200
native-window-placement: Adjust to gnome-shell changes
The extension was affected pretty badly by the window picker overhaul;
adjust to all(?) the major and minor changes to get it to work again.
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/124
extensions/native-window-placement/extension.js | 35 ++++++++++++++-----------
1 file changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js
index a91d193..de8dec0 100644
--- a/extensions/native-window-placement/extension.js
+++ b/extensions/native-window-placement/extension.js
@@ -1,6 +1,9 @@
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
/* exported enable disable */
+const { Clutter } = imports.gi;
+
const ExtensionUtils = imports.misc.extensionUtils;
+const { WindowPreview } = imports.ui.windowPreview;
const Workspace = imports.ui.workspace;
// testing settings for natural window placement strategy:
@@ -221,8 +224,10 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy {
for (let i = 0; i < rects.length; i++) {
rects[i].x = rects[i].x * scale + areaRect.x;
rects[i].y = rects[i].y * scale + areaRect.y;
+ rects[i].width *= scale;
+ rects[i].height *= scale;
- slots.push([rects[i].x, rects[i].y, scale, clones[i]]);
+ slots.push([rects[i].x, rects[i].y, rects[i].width, rects[i].height, clones[i]]);
}
return slots;
@@ -241,24 +246,24 @@ function enable() {
let settings = ExtensionUtils.getSettings();
- workspaceInjections['_getBestLayout'] = Workspace.Workspace.prototype._getBestLayout;
- Workspace.Workspace.prototype._getBestLayout = function (windows) {
+ workspaceInjections['_createBestLayout'] = Workspace.WorkspaceLayout.prototype._createBestLayout;
+ Workspace.WorkspaceLayout.prototype._createBestLayout = function (area) {
let strategy = new NaturalLayoutStrategy(settings);
- let layout = { strategy };
- strategy.computeLayout(windows, layout);
+ let layout = { area, strategy };
+ strategy.computeLayout(this._sortedWindows, layout);
return layout;
};
// position window titles on top of windows in overlay
- winInjections['relayout'] = Workspace.WindowOverlay.prototype.relayout;
- Workspace.WindowOverlay.prototype.relayout = function (animate) {
- if (settings.get_boolean('window-captions-on-top')) {
- let [, , , cloneHeight] = this._windowClone.slot;
- this.title.translation_y = -cloneHeight;
- }
-
- winInjections['relayout'].call(this, animate);
+ winInjections['_init'] = WindowPreview.prototype._init;
+ WindowPreview.prototype._init = function (metaWindow, workspace) {
+ winInjections['_init'].call(this, metaWindow, workspace);
+
+ const constraint = this._title.get_constraints().find(
+ c => c.align_axis && c.align_axis === Clutter.AlignAxis.Y_AXIS);
+ constraint.factor = settings.get_boolean('window-captions-on-top')
+ ? 0 : 1;
};
}
@@ -273,9 +278,9 @@ function disable() {
var i;
for (i in workspaceInjections)
- removeInjection(Workspace.Workspace.prototype, workspaceInjections, i);
+ removeInjection(Workspace.WorkspaceLayout.prototype, workspaceInjections, i);
for (i in winInjections)
- removeInjection(Workspace.WindowOverlay.prototype, winInjections, i);
+ removeInjection(WindowPreview.prototype, winInjections, i);
global.stage.queue_relayout();
resetState();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]