use directional names
This commit is contained in:
@@ -7,41 +7,41 @@ namespace Actions {
|
||||
|
||||
public "focus-left"() {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
if (prevColumn === null) {
|
||||
const leftColumn = grid.getLeftColumn(column);
|
||||
if (leftColumn === null) {
|
||||
return;
|
||||
}
|
||||
prevColumn.focus();
|
||||
leftColumn.focus();
|
||||
});
|
||||
}
|
||||
|
||||
public "focus-right"() {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
if (nextColumn === null) {
|
||||
const rightColumn = grid.getRightColumn(column);
|
||||
if (rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
nextColumn.focus();
|
||||
rightColumn.focus();
|
||||
});
|
||||
}
|
||||
|
||||
public "focus-up"() {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
const prevWindow = column.getPrevWindow(window);
|
||||
if (prevWindow === null) {
|
||||
const aboveWindow = column.getAboveWindow(window);
|
||||
if (aboveWindow === null) {
|
||||
return;
|
||||
}
|
||||
prevWindow.focus();
|
||||
aboveWindow.focus();
|
||||
});
|
||||
}
|
||||
|
||||
public "focus-down"() {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
const nextWindow = column.getNextWindow(window);
|
||||
if (nextWindow === null) {
|
||||
const belowWindow = column.getBelowWindow(window);
|
||||
if (belowWindow === null) {
|
||||
return;
|
||||
}
|
||||
nextWindow.focus();
|
||||
belowWindow.focus();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,15 +71,15 @@ namespace Actions {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
if (prevColumn === null) {
|
||||
const leftColumn = grid.getLeftColumn(column);
|
||||
if (leftColumn === null) {
|
||||
return;
|
||||
}
|
||||
window.moveToColumn(prevColumn);
|
||||
window.moveToColumn(leftColumn);
|
||||
grid.desktop.autoAdjustScroll();
|
||||
} else {
|
||||
// move from shared column into own column
|
||||
const newColumn = new Column(grid, grid.getPrevColumn(column));
|
||||
const newColumn = new Column(grid, grid.getLeftColumn(column));
|
||||
window.moveToColumn(newColumn);
|
||||
}
|
||||
});
|
||||
@@ -89,11 +89,11 @@ namespace Actions {
|
||||
this.world.doIfTiledFocused((clientManager, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
if (nextColumn === null) {
|
||||
const rightColumn = grid.getRightColumn(column);
|
||||
if (rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
window.moveToColumn(nextColumn);
|
||||
window.moveToColumn(rightColumn);
|
||||
grid.desktop.autoAdjustScroll();
|
||||
} else {
|
||||
// move from shared column into own column
|
||||
@@ -230,12 +230,12 @@ namespace Actions {
|
||||
return;
|
||||
}
|
||||
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
if (prevColumn === null) {
|
||||
const leftColumn = grid.getLeftColumn(column);
|
||||
if (leftColumn === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
grid.desktop.scrollToColumn(prevColumn);
|
||||
grid.desktop.scrollToColumn(leftColumn);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -247,12 +247,12 @@ namespace Actions {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
if (nextColumn === null) {
|
||||
const rightColumn = grid.getRightColumn(column);
|
||||
if (rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
grid.desktop.scrollToColumn(nextColumn);
|
||||
grid.desktop.scrollToColumn(rightColumn);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Actions {
|
||||
if (targetColumn.isToTheRightOf(column)) {
|
||||
grid.moveColumn(column, targetColumn);
|
||||
} else {
|
||||
grid.moveColumn(column, grid.getPrevColumn(targetColumn));
|
||||
grid.moveColumn(column, grid.getLeftColumn(targetColumn));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -50,11 +50,11 @@ class ContextualResizer {
|
||||
return;
|
||||
}
|
||||
|
||||
let leftOffScreenColumn = grid.getPrevColumn(leftVisibleColumn);
|
||||
let leftOffScreenColumn = grid.getLeftColumn(leftVisibleColumn);
|
||||
if (leftOffScreenColumn === column) {
|
||||
leftOffScreenColumn = null;
|
||||
}
|
||||
let rightOffScreenColumn = grid.getNextColumn(rightVisibleColumn);
|
||||
let rightOffScreenColumn = grid.getRightColumn(rightVisibleColumn);
|
||||
if (rightOffScreenColumn === column) {
|
||||
rightOffScreenColumn = null;
|
||||
}
|
||||
|
||||
@@ -7,23 +7,23 @@ class Column {
|
||||
private focusTaker: Window|null;
|
||||
private static readonly minWidth = 10;
|
||||
|
||||
constructor(grid: Grid, prevColumn: Column|null) {
|
||||
constructor(grid: Grid, leftColumn: Column|null) {
|
||||
this.gridX = 0;
|
||||
this.width = 0;
|
||||
this.windows = new LinkedList();
|
||||
this.stacked = grid.config.stackColumnsByDefault;
|
||||
this.focusTaker = null;
|
||||
this.grid = grid;
|
||||
this.grid.onColumnAdded(this, prevColumn);
|
||||
this.grid.onColumnAdded(this, leftColumn);
|
||||
}
|
||||
|
||||
public moveToGrid(targetGrid: Grid, prevColumn: Column|null) {
|
||||
public moveToGrid(targetGrid: Grid, leftColumn: Column|null) {
|
||||
if (targetGrid === this.grid) {
|
||||
this.grid.moveColumn(this, prevColumn);
|
||||
this.grid.moveColumn(this, leftColumn);
|
||||
} else {
|
||||
this.grid.onColumnRemoved(this, false);
|
||||
this.grid = targetGrid;
|
||||
targetGrid.onColumnAdded(this, prevColumn);
|
||||
targetGrid.onColumnAdded(this, leftColumn);
|
||||
for (const window of this.windows.iterator()) {
|
||||
window.client.kwinClient.desktops = [targetGrid.desktop.kwinDesktop];
|
||||
}
|
||||
@@ -56,11 +56,11 @@ class Column {
|
||||
return this.getWindowCount() === 0;
|
||||
}
|
||||
|
||||
public getPrevWindow(window: Window) {
|
||||
public getAboveWindow(window: Window) {
|
||||
return this.windows.getPrev(window);
|
||||
}
|
||||
|
||||
public getNextWindow(window: Window) {
|
||||
public getBelowWindow(window: Window) {
|
||||
return this.windows.getNext(window);
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ class Column {
|
||||
|
||||
public onWindowRemoved(window: Window, passFocus: boolean) {
|
||||
const lastWindow = this.windows.length() === 1;
|
||||
const windowToFocus = this.getPrevWindow(window) ?? this.getNextWindow(window);
|
||||
const windowToFocus = this.getAboveWindow(window) ?? this.getBelowWindow(window);
|
||||
|
||||
this.windows.remove(window);
|
||||
|
||||
|
||||
@@ -251,8 +251,8 @@ namespace Desktop {
|
||||
return column !== null && canFit(column);
|
||||
}
|
||||
|
||||
let leftColumn = grid.getPrevColumn(this.left);
|
||||
let rightColumn = grid.getNextColumn(this.right);
|
||||
let leftColumn = grid.getLeftColumn(this.left);
|
||||
let rightColumn = grid.getRightColumn(this.right);
|
||||
function checkColumns() {
|
||||
if (!isUsable(leftColumn)) {
|
||||
leftColumn = null;
|
||||
@@ -269,10 +269,10 @@ namespace Desktop {
|
||||
const rightToCenter = rightColumn === null ? Infinity : Math.abs(rightColumn.getRight() - visibleCenter);
|
||||
if (leftToCenter < rightToCenter) {
|
||||
this.addLeft(leftColumn!, gap);
|
||||
leftColumn = grid.getPrevColumn(leftColumn!);
|
||||
leftColumn = grid.getLeftColumn(leftColumn!);
|
||||
} else {
|
||||
this.addRight(rightColumn!, gap);
|
||||
rightColumn = grid.getNextColumn(rightColumn!);
|
||||
rightColumn = grid.getRightColumn(rightColumn!);
|
||||
}
|
||||
checkColumns();
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ class Grid {
|
||||
});
|
||||
}
|
||||
|
||||
public moveColumn(column: Column, prevColumn: Column|null) {
|
||||
if (column === prevColumn) {
|
||||
public moveColumn(column: Column, leftColumn: Column|null) {
|
||||
if (column === leftColumn) {
|
||||
return;
|
||||
}
|
||||
const movedLeft = prevColumn === null ? true : column.isToTheRightOf(prevColumn);
|
||||
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
|
||||
this.columns.move(column, prevColumn);
|
||||
const movedLeft = leftColumn === null ? true : column.isToTheRightOf(leftColumn);
|
||||
const firstMovedColumn = movedLeft ? column : this.getRightColumn(column);
|
||||
this.columns.move(column, leftColumn);
|
||||
this.columnsSetX(firstMovedColumn);
|
||||
this.desktop.onLayoutChanged();
|
||||
this.desktop.autoAdjustScroll();
|
||||
@@ -44,11 +44,11 @@ class Grid {
|
||||
}
|
||||
|
||||
public moveColumnRight(column: Column) {
|
||||
const nextColumn = this.columns.getNext(column);
|
||||
if (nextColumn === null) {
|
||||
const rightColumn = this.columns.getNext(column);
|
||||
if (rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
this.moveColumnLeft(nextColumn);
|
||||
this.moveColumnLeft(rightColumn);
|
||||
}
|
||||
|
||||
public getWidth() {
|
||||
@@ -59,11 +59,11 @@ class Grid {
|
||||
return this.userResize;
|
||||
}
|
||||
|
||||
public getPrevColumn(column: Column) {
|
||||
public getLeftColumn(column: Column) {
|
||||
return this.columns.getPrev(column);
|
||||
}
|
||||
|
||||
public getNextColumn(column: Column) {
|
||||
public getRightColumn(column: Column) {
|
||||
return this.columns.getNext(column);
|
||||
}
|
||||
|
||||
@@ -162,11 +162,11 @@ class Grid {
|
||||
}
|
||||
}
|
||||
|
||||
public onColumnAdded(column: Column, prevColumn: Column|null) {
|
||||
if (prevColumn === null) {
|
||||
public onColumnAdded(column: Column, leftColumn: Column|null) {
|
||||
if (leftColumn === null) {
|
||||
this.columns.insertStart(column);
|
||||
} else {
|
||||
this.columns.insertAfter(column, prevColumn);
|
||||
this.columns.insertAfter(column, leftColumn);
|
||||
}
|
||||
this.columnsSetX(column);
|
||||
this.desktop.onLayoutChanged();
|
||||
@@ -175,14 +175,14 @@ class Grid {
|
||||
|
||||
public onColumnRemoved(column: Column, passFocus: boolean) {
|
||||
const isLastColumn = this.columns.length() === 1;
|
||||
const nextColumn = this.getNextColumn(column);
|
||||
const columnToFocus = isLastColumn ? null : this.getPrevColumn(column) ?? nextColumn;
|
||||
const rightColumn = this.getRightColumn(column);
|
||||
const columnToFocus = isLastColumn ? null : this.getLeftColumn(column) ?? rightColumn;
|
||||
if (column === this.lastFocusedColumn) {
|
||||
this.lastFocusedColumn = columnToFocus;
|
||||
}
|
||||
|
||||
this.columns.remove(column);
|
||||
this.columnsSetX(nextColumn);
|
||||
this.columnsSetX(rightColumn);
|
||||
|
||||
this.desktop.onLayoutChanged();
|
||||
if (passFocus && columnToFocus !== null) {
|
||||
@@ -193,8 +193,8 @@ class Grid {
|
||||
}
|
||||
|
||||
public onColumnWidthChanged(column: Column) {
|
||||
const nextColumn = this.columns.getNext(column);
|
||||
this.columnsSetX(nextColumn);
|
||||
const rightColumn = this.columns.getNext(column);
|
||||
this.columnsSetX(rightColumn);
|
||||
this.desktop.onLayoutChanged();
|
||||
if (!this.userResize) {
|
||||
this.desktop.autoAdjustScroll();
|
||||
|
||||
@@ -116,7 +116,7 @@ class Window {
|
||||
let leftEdgeDelta = newGeometry.left - oldGeometry.left;
|
||||
const resizingLeftSide = leftEdgeDelta !== 0;
|
||||
if (resizeNeighborColumn && this.column.grid.config.resizeNeighborColumn) {
|
||||
const neighborColumn = resizingLeftSide ? this.column.grid.getPrevColumn(this.column) : this.column.grid.getNextColumn(this.column);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user