prevent pushing columns with min-width on edge resize
This commit is contained in:
@@ -107,7 +107,11 @@ class Window {
|
||||
this.column.grid.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onUserResize(oldGeometry: QmlRect, resizeNeighborColumn: boolean) {
|
||||
public onUserResize(
|
||||
oldGeometry: QmlRect,
|
||||
startWidth: number,
|
||||
neighbor?: { column: Column, startWidth: number },
|
||||
) {
|
||||
const newGeometry = this.client.kwinClient.frameGeometry;
|
||||
const widthDelta = newGeometry.width - oldGeometry.width;
|
||||
const heightDelta = newGeometry.height - oldGeometry.height;
|
||||
@@ -115,14 +119,12 @@ class Window {
|
||||
this.column.adjustWidth(widthDelta, true);
|
||||
let leftEdgeDelta = newGeometry.left - oldGeometry.left;
|
||||
const resizingLeftSide = leftEdgeDelta !== 0;
|
||||
if (resizeNeighborColumn && this.column.grid.config.resizeNeighborColumn) {
|
||||
const neighborColumn = resizingLeftSide ? this.column.grid.getLeftColumn(this.column) : this.column.grid.getRightColumn(this.column);
|
||||
if (neighborColumn !== null) {
|
||||
const oldNeighborWidth = neighborColumn.getWidth();
|
||||
neighborColumn.adjustWidth(-widthDelta, true);
|
||||
if (resizingLeftSide) {
|
||||
leftEdgeDelta -= neighborColumn.getWidth() - oldNeighborWidth;
|
||||
}
|
||||
if (neighbor !== undefined) {
|
||||
const widthDeltaTotal = newGeometry.width - startWidth;
|
||||
const oldNeighborWidth = neighbor.column.getWidth();
|
||||
neighbor.column.setWidth(neighbor.startWidth - widthDeltaTotal, true);
|
||||
if (resizingLeftSide) {
|
||||
leftEdgeDelta -= neighbor.column.getWidth() - oldNeighborWidth;
|
||||
}
|
||||
}
|
||||
this.column.grid.desktop.adjustScroll(-leftEdgeDelta, true);
|
||||
|
||||
@@ -70,7 +70,8 @@ namespace ClientState {
|
||||
});
|
||||
|
||||
let resizing = false;
|
||||
let resizingBorder = false;
|
||||
let resizeStartWidth = 0;
|
||||
let resizeNeighbor: { column: Column, startWidth: number } | undefined;
|
||||
manager.connect(kwinClient.interactiveMoveResizeStarted, () => {
|
||||
if (kwinClient.move) {
|
||||
if (config.untileOnDrag) {
|
||||
@@ -83,8 +84,16 @@ namespace ClientState {
|
||||
|
||||
if (kwinClient.resize) {
|
||||
resizing = true;
|
||||
resizingBorder = Workspace.cursorPos.x > kwinClient.clientGeometry.right ||
|
||||
Workspace.cursorPos.x < kwinClient.clientGeometry.left;
|
||||
resizeStartWidth = kwinClient.frameGeometry.width;
|
||||
if (config.resizeNeighborColumn) {
|
||||
const resizeNeighborColumn = Tiled.getResizeNeighborColumn(window);
|
||||
if (resizeNeighborColumn !== null) {
|
||||
resizeNeighbor = {
|
||||
column: resizeNeighborColumn,
|
||||
startWidth: resizeNeighborColumn.getWidth(),
|
||||
};
|
||||
}
|
||||
}
|
||||
window.column.grid.onUserResizeStarted();
|
||||
}
|
||||
});
|
||||
@@ -92,6 +101,7 @@ namespace ClientState {
|
||||
manager.connect(kwinClient.interactiveMoveResizeFinished, () => {
|
||||
if (resizing) {
|
||||
resizing = false;
|
||||
resizeNeighbor = undefined;
|
||||
window.column.grid.onUserResizeFinished();
|
||||
}
|
||||
});
|
||||
@@ -120,7 +130,7 @@ namespace ClientState {
|
||||
}
|
||||
|
||||
if (kwinClient.resize) {
|
||||
world.do(() => window.onUserResize(oldGeometry, resizingBorder));
|
||||
world.do(() => window.onUserResize(oldGeometry, resizeStartWidth, resizeNeighbor));
|
||||
} else if (
|
||||
!window.column.grid.isUserResizing() &&
|
||||
!client.isManipulatingGeometry(newGeometry) &&
|
||||
@@ -149,6 +159,18 @@ namespace ClientState {
|
||||
return manager;
|
||||
}
|
||||
|
||||
private static getResizeNeighborColumn(window: Window) {
|
||||
const kwinClient = window.client.kwinClient;
|
||||
const column = window.column;
|
||||
if (Workspace.cursorPos.x > kwinClient.clientGeometry.right) {
|
||||
return column.grid.getRightColumn(column);
|
||||
} else if (Workspace.cursorPos.x < kwinClient.clientGeometry.left) {
|
||||
return column.grid.getLeftColumn(column);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static moveWindowToGrid(window: Window, grid: Grid) {
|
||||
if (grid === window.column.grid) {
|
||||
// window already on the given grid
|
||||
|
||||
@@ -65,9 +65,8 @@ tests.register("User resize", 10, () => {
|
||||
workspaceMock.resizeWindow(clientLeft, true, false, false, new MockQmlSize(10, 20));
|
||||
assertSizes(310, 295, h, h);
|
||||
|
||||
// TODO
|
||||
// workspaceMock.resizeWindow(clientLeft, true, false, false, new MockQmlSize(10, 0), new MockQmlSize(-10, 0));
|
||||
// assertSizes(310, 295, h, h);
|
||||
workspaceMock.resizeWindow(clientLeft, true, false, false, new MockQmlSize(10, 0), new MockQmlSize(-10, 0));
|
||||
assertSizes(310, 295, h, h);
|
||||
|
||||
workspaceMock.resizeWindow(clientRightTop, true, false, false, new MockQmlSize(-5, -10), new MockQmlSize(-5, -10));
|
||||
assertSizes(310, 295, h-20, h+20);
|
||||
|
||||
Reference in New Issue
Block a user