resize neighbor column on edge resize

This commit is contained in:
Peter Fajdiga
2023-06-24 12:38:31 +02:00
parent 6e9edad39d
commit e2a5625d41
3 changed files with 24 additions and 7 deletions

View File

@@ -132,9 +132,8 @@ class Grid {
for (const column of this.columns.iteratorFrom(startColumn)) {
if (column !== endColumn) {
const newWidth = Math.round(column.width * scaleRatio);
column.setWidth(newWidth, true);
remainingWidth -= newWidth + this.world.config.gapsInnerHorizontal;
column.setWidth(Math.round(column.width * scaleRatio), true);
remainingWidth -= column.width + this.world.config.gapsInnerHorizontal;
} else {
column.setWidth(remainingWidth, true);
break;

View File

@@ -83,15 +83,25 @@ class Window {
}
}
onUserResize(oldGeometry: QRect) {
onUserResize(oldGeometry: QRect, resizeNeighborColumn: boolean) {
const newGeometry = this.client.kwinClient.frameGeometry;
const widthDelta = newGeometry.width - oldGeometry.width;
const heightDelta = newGeometry.height - oldGeometry.height;
if (widthDelta !== 0) {
this.column.adjustWidth(widthDelta, true);
if (newGeometry.x !== oldGeometry.x) {
this.column.grid.adjustScroll(widthDelta, true);
let leftEdgeDelta = newGeometry.left - oldGeometry.left;
const resizingLeftSide = leftEdgeDelta !== 0;
if (resizeNeighborColumn) {
const neighborColumn = resizingLeftSide ? this.column.grid.getPrevColumn(this.column) : this.column.grid.getNextColumn(this.column);
if (neighborColumn !== null) {
const oldNeighborWidth = neighborColumn.width;
neighborColumn.adjustWidth(-widthDelta, true);
if (resizingLeftSide) {
leftEdgeDelta -= neighborColumn.width - oldNeighborWidth;
}
}
}
this.column.grid.adjustScroll(-leftEdgeDelta, true);
}
if (heightDelta !== 0) {
this.column.adjustWindowHeight(this, heightDelta, newGeometry.y !== oldGeometry.y);

View File

@@ -67,11 +67,19 @@ class ClientStateTiled {
lastResize = resize;
});
let cursorChangedAfterResizeStart = false;
manager.connect(kwinClient.moveResizeCursorChanged, () => {
cursorChangedAfterResizeStart = true;
});
manager.connect(kwinClient.clientStartUserMovedResized, () => {
cursorChangedAfterResizeStart = false;
});
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: TopLevel, oldGeometry: QRect) => {
console.assert(!kwinClient.move, "moved clients are removed in kwinClient.moveResizedChanged");
const grid = window.column.grid;
if (kwinClient.resize) {
window.onUserResize(oldGeometry);
window.onUserResize(oldGeometry, !cursorChangedAfterResizeStart);
grid.arrange();
} else {
const maximized = rectEqual(kwinClient.frameGeometry, grid.clientArea);