native-window-placement: Adjust to gnome-shell changes
More unsurprising breakage: - the workspace layout/strategy relation has been cleaned up - window previews now include an icon that influences the title position - window previews scale up on hover, which again influences the title position Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/164>
This commit is contained in:
committed by
Marge Bot
parent
7ace9c4d51
commit
7062acf10f
@@ -3,6 +3,7 @@
|
||||
const { Clutter } = imports.gi;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Main = imports.ui.main;
|
||||
const { WindowPreview } = imports.ui.windowPreview;
|
||||
const Workspace = imports.ui.workspace;
|
||||
|
||||
@@ -66,13 +67,15 @@ class Rect {
|
||||
}
|
||||
|
||||
class NaturalLayoutStrategy extends Workspace.LayoutStrategy {
|
||||
constructor(settings) {
|
||||
super();
|
||||
constructor(params, settings) {
|
||||
super(params);
|
||||
this._settings = settings;
|
||||
}
|
||||
|
||||
computeLayout(windows, layout) {
|
||||
layout.windows = windows;
|
||||
computeLayout(windows, _params) {
|
||||
return {
|
||||
windows,
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -246,23 +249,36 @@ function enable() {
|
||||
let settings = ExtensionUtils.getSettings();
|
||||
|
||||
workspaceInjections['_createBestLayout'] = Workspace.WorkspaceLayout.prototype._createBestLayout;
|
||||
Workspace.WorkspaceLayout.prototype._createBestLayout = function (area) {
|
||||
let strategy = new NaturalLayoutStrategy(settings);
|
||||
let layout = { area, strategy };
|
||||
strategy.computeLayout(this._sortedWindows, layout);
|
||||
|
||||
return layout;
|
||||
Workspace.WorkspaceLayout.prototype._createBestLayout = function (_area) {
|
||||
this._layoutStrategy = new NaturalLayoutStrategy({
|
||||
monitor: Main.layoutManager.monitors[this._monitorIndex],
|
||||
}, settings);
|
||||
return this._layoutStrategy.computeLayout(this._sortedWindows);
|
||||
};
|
||||
|
||||
// position window titles on top of windows in overlay
|
||||
winInjections['_init'] = WindowPreview.prototype._init;
|
||||
WindowPreview.prototype._init = function (metaWindow, workspace) {
|
||||
winInjections['_init'].call(this, metaWindow, workspace);
|
||||
WindowPreview.prototype._init = function (...args) {
|
||||
winInjections['_init'].call(this, ...args);
|
||||
|
||||
const constraint = this._title.get_constraints().find(
|
||||
if (!settings.get_boolean('window-captions-on-top'))
|
||||
return;
|
||||
|
||||
const alignConstraint = 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;
|
||||
alignConstraint.factor = 0;
|
||||
|
||||
const bindConstraint = this._title.get_constraints().find(
|
||||
c => c.coordinate && c.coordinate === Clutter.BindCoordinate.Y);
|
||||
bindConstraint.offset = 0;
|
||||
};
|
||||
winInjections['_adjustOverlayOffsets'] =
|
||||
WindowPreview.prototype._adjustOverlayOffsets;
|
||||
WindowPreview.prototype._adjustOverlayOffsets = function (...args) {
|
||||
winInjections['_adjustOverlayOffsets'].call(this, ...args);
|
||||
|
||||
if (settings.get_boolean('window-captions-on-top'))
|
||||
this._title.translation_y = -this._title.translation_y;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user