update column widths after screen size change

This commit is contained in:
Peter Fajdiga
2023-08-25 12:46:01 +02:00
parent 453c4ece2c
commit e580acf979
2 changed files with 14 additions and 0 deletions

View File

@@ -108,6 +108,19 @@ class Column {
this.setWidth(this.width + widthDelta, setPreferred);
}
public updateWidth() {
let minErr = Infinity;
let closestPreferredWidth = this.width;
for (const window of this.windows.iterator()) {
const err = Math.abs(window.client.preferredWidth - this.width);
if (err < minErr) {
minErr = err;
closestPreferredWidth = window.client.preferredWidth;
}
}
this.setWidth(closestPreferredWidth, false);
}
// returns x position of left edge in grid space
public getLeft() {
return this.gridX;

View File

@@ -276,6 +276,7 @@ class Grid {
public onScreenSizeChanged() {
for (const column of this.columns.iterator()) {
column.updateWidth();
column.resizeWindows();
}
}