mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-06 20:07:02 +00:00
kludges: use 3.38 computeLayout
This commit is contained in:
+63
-2
@@ -379,8 +379,12 @@ function init() {
|
||||
});
|
||||
}
|
||||
|
||||
if (version[1] > 32 && version[1] < 37)
|
||||
registerOverridePrototype(Workspace.UnalignedLayoutStrategy, 'computeLayout', computeLayout);
|
||||
let layout = computeLayout
|
||||
if (version[1] > 37)
|
||||
layout = computeLayout338
|
||||
|
||||
if (version[1] > 32)
|
||||
registerOverridePrototype(Workspace.UnalignedLayoutStrategy, 'computeLayout', layout);
|
||||
|
||||
// Kill pinch gestures as they work pretty bad (especially when 3-finger swiping)
|
||||
registerOverrideProp(imports.ui.viewSelector, "PINCH_GESTURE_THRESHOLD", 0);
|
||||
@@ -594,6 +598,63 @@ function computeLayout(windows, layout) {
|
||||
layout.gridHeight = gridHeight;
|
||||
}
|
||||
|
||||
function computeLayout338(windows, layout) {
|
||||
let numRows = layout.numRows;
|
||||
|
||||
let rows = [];
|
||||
let totalWidth = 0;
|
||||
for (let i = 0; i < windows.length; i++) {
|
||||
let window = windows[i];
|
||||
let s = this._computeWindowScale(window);
|
||||
totalWidth += window.boundingBox.width * s;
|
||||
}
|
||||
|
||||
let idealRowWidth = totalWidth / numRows;
|
||||
|
||||
// Sort windows vertically to minimize travel distance.
|
||||
// This affects what rows the windows get placed in.
|
||||
let sortedWindows = windows.slice();
|
||||
sortedWindows.sort((a, b) => a.windowCenter.y - b.windowCenter.y);
|
||||
|
||||
let windowIdx = 0;
|
||||
for (let i = 0; i < numRows; i++) {
|
||||
let row = this._newRow();
|
||||
rows.push(row);
|
||||
|
||||
for (; windowIdx < sortedWindows.length; windowIdx++) {
|
||||
let window = sortedWindows[windowIdx];
|
||||
let s = this._computeWindowScale(window);
|
||||
let width = window.boundingBox.width * s;
|
||||
let height = window.boundingBox.height * s;
|
||||
row.fullHeight = Math.max(row.fullHeight, height);
|
||||
|
||||
// either new width is < idealWidth or new width is nearer from idealWidth then oldWidth
|
||||
if (this._keepSameRow(row, window, width, idealRowWidth) || (i == numRows - 1)) {
|
||||
row.windows.push(window);
|
||||
row.fullWidth += width;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let gridHeight = 0;
|
||||
let maxRow;
|
||||
for (let i = 0; i < numRows; i++) {
|
||||
let row = rows[i];
|
||||
this._sortRow(row);
|
||||
|
||||
if (!maxRow || row.fullWidth > maxRow.fullWidth)
|
||||
maxRow = row;
|
||||
gridHeight += row.fullHeight;
|
||||
}
|
||||
|
||||
layout.rows = rows;
|
||||
layout.maxColumns = maxRow.windows.length;
|
||||
layout.gridWidth = maxRow.fullWidth;
|
||||
layout.gridHeight = gridHeight;
|
||||
}
|
||||
|
||||
const wmSettings = new Gio.Settings({schema_id: 'org.gnome.desktop.wm.preferences'});
|
||||
function _checkWorkspaces() {
|
||||
let workspaceManager = global.workspace_manager;
|
||||
|
||||
Reference in New Issue
Block a user