rename ScrollView to Desktop
This commit is contained in:
@@ -2,7 +2,7 @@ module Actions {
|
||||
export function init(world: World, config: Config) {
|
||||
return {
|
||||
focusLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
if (prevColumn === null) {
|
||||
return;
|
||||
@@ -12,7 +12,7 @@ module Actions {
|
||||
},
|
||||
|
||||
focusRight: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
if (nextColumn === null) {
|
||||
return;
|
||||
@@ -22,7 +22,7 @@ module Actions {
|
||||
},
|
||||
|
||||
focusUp: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const prevWindow = column.getPrevWindow(window);
|
||||
if (prevWindow === null) {
|
||||
return;
|
||||
@@ -32,7 +32,7 @@ module Actions {
|
||||
},
|
||||
|
||||
focusDown: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const nextWindow = column.getNextWindow(window);
|
||||
if (nextWindow === null) {
|
||||
return;
|
||||
@@ -42,8 +42,8 @@ module Actions {
|
||||
},
|
||||
|
||||
focusStart: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const firstColumn = grid.getFirstColumn();
|
||||
if (firstColumn === null) {
|
||||
return;
|
||||
@@ -53,8 +53,8 @@ module Actions {
|
||||
},
|
||||
|
||||
focusEnd: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const lastColumn = grid.getLastColumn();
|
||||
if (lastColumn === null) {
|
||||
return;
|
||||
@@ -64,7 +64,7 @@ module Actions {
|
||||
},
|
||||
|
||||
windowMoveLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
@@ -82,7 +82,7 @@ module Actions {
|
||||
},
|
||||
|
||||
windowMoveRight: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
@@ -101,27 +101,27 @@ module Actions {
|
||||
|
||||
windowMoveUp: () => {
|
||||
// TODO (optimization): only arrange moved windows
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
column.moveWindowUp(window);
|
||||
});
|
||||
},
|
||||
|
||||
windowMoveDown: () => {
|
||||
// TODO (optimization): only arrange moved windows
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
column.moveWindowDown(window);
|
||||
});
|
||||
},
|
||||
|
||||
windowMoveStart: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const newColumn = new Column(grid, null);
|
||||
window.moveToColumn(newColumn);
|
||||
});
|
||||
},
|
||||
|
||||
windowMoveEnd: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const newColumn = new Column(grid, grid.getLastColumn());
|
||||
window.moveToColumn(newColumn);
|
||||
});
|
||||
@@ -129,49 +129,49 @@ module Actions {
|
||||
|
||||
windowToggleFloating: () => {
|
||||
const kwinClient = workspace.activeClient;
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.toggleFloatingClient(kwinClient);
|
||||
});
|
||||
},
|
||||
|
||||
columnMoveLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
grid.moveColumnLeft(column);
|
||||
});
|
||||
},
|
||||
|
||||
columnMoveRight: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
grid.moveColumnRight(column);
|
||||
});
|
||||
},
|
||||
|
||||
columnMoveStart: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(null);
|
||||
});
|
||||
},
|
||||
|
||||
columnMoveEnd: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(grid.getLastColumn());
|
||||
});
|
||||
},
|
||||
|
||||
columnToggleStacked: () => {
|
||||
world.doIfTiledFocused(false, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
column.toggleStacked();
|
||||
});
|
||||
},
|
||||
|
||||
columnWidthIncrease: () => {
|
||||
world.doIfTiledFocused(false, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
grid.increaseColumnWidth(column);
|
||||
});
|
||||
},
|
||||
|
||||
columnWidthDecrease: () => {
|
||||
world.doIfTiledFocused(false, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
grid.decreaseColumnWidth(column);
|
||||
});
|
||||
},
|
||||
@@ -185,8 +185,8 @@ module Actions {
|
||||
},
|
||||
|
||||
gridScrollStart: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const firstColumn = grid.getFirstColumn();
|
||||
if (firstColumn === null) {
|
||||
return;
|
||||
@@ -196,8 +196,8 @@ module Actions {
|
||||
},
|
||||
|
||||
gridScrollEnd: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const lastColumn = grid.getLastColumn();
|
||||
if (lastColumn === null) {
|
||||
return;
|
||||
@@ -207,14 +207,14 @@ module Actions {
|
||||
},
|
||||
|
||||
gridScrollFocused: () => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
grid.container.scrollCenterColumn(column);
|
||||
})
|
||||
},
|
||||
|
||||
gridScrollLeftColumn: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const column = grid.getLeftmostVisibleColumn(grid.container.getCurrentScrollPos(), true);
|
||||
if (column === null) {
|
||||
return;
|
||||
@@ -230,8 +230,8 @@ module Actions {
|
||||
},
|
||||
|
||||
gridScrollRightColumn: () => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const column = grid.getRightmostVisibleColumn(grid.container.getCurrentScrollPos(), true);
|
||||
if (column === null) {
|
||||
return;
|
||||
@@ -251,8 +251,8 @@ module Actions {
|
||||
export function initNum(world: World) {
|
||||
return {
|
||||
focusColumn: (columnIndex: number) => {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null) {
|
||||
return null;
|
||||
@@ -262,7 +262,7 @@ module Actions {
|
||||
},
|
||||
|
||||
windowMoveToColumn: (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null) {
|
||||
return null;
|
||||
@@ -273,7 +273,7 @@ module Actions {
|
||||
},
|
||||
|
||||
columnMoveToColumn: (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (world, svm, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null || targetColumn === column) {
|
||||
return null;
|
||||
@@ -287,9 +287,9 @@ module Actions {
|
||||
},
|
||||
|
||||
columnMoveToDesktop: (desktopIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, svm, window, column, oldGrid) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
||||
const desktopNumber = desktopIndex + 1;
|
||||
const newGrid = svm.getInCurrentActivity(desktopNumber).grid;
|
||||
const newGrid = desktopManager.getInCurrentActivity(desktopNumber).grid;
|
||||
if (newGrid === null || newGrid === oldGrid) {
|
||||
return;
|
||||
}
|
||||
@@ -298,9 +298,9 @@ module Actions {
|
||||
},
|
||||
|
||||
tailMoveToDesktop: (desktopIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, svm, window, column, oldGrid) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
||||
const desktopNumber = desktopIndex + 1;
|
||||
const newGrid = svm.getInCurrentActivity(desktopNumber).grid;
|
||||
const newGrid = desktopManager.getInCurrentActivity(desktopNumber).grid;
|
||||
if (newGrid === null || newGrid === oldGrid) {
|
||||
return;
|
||||
}
|
||||
@@ -311,8 +311,8 @@ module Actions {
|
||||
}
|
||||
|
||||
function gridScroll(world: World, amount: number) {
|
||||
world.do((clientManager, svm) => {
|
||||
const grid = svm.getCurrent().grid;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrent().grid;
|
||||
grid.container.adjustScroll(amount, false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class Column {
|
||||
this.grid.container.onLayoutChanged();
|
||||
}
|
||||
|
||||
public isVisible(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
public isVisible(scrollPos: Desktop.Pos, fullyVisible: boolean) {
|
||||
if (fullyVisible) {
|
||||
return this.getLeft() >= scrollPos.getLeft() &&
|
||||
this.getRight() <= scrollPos.getRight();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class ScrollView {
|
||||
class Desktop {
|
||||
public readonly grid: Grid;
|
||||
public readonly desktopNumber: number;
|
||||
private readonly config: ScrollView.Config;
|
||||
private readonly config: Desktop.Config;
|
||||
private scrollX: number;
|
||||
private dirty: boolean;
|
||||
public clientArea: QRect;
|
||||
public tilingArea: QRect;
|
||||
|
||||
constructor(desktopNumber: number, config: ScrollView.Config, layoutConfig: LayoutConfig) {
|
||||
constructor(desktopNumber: number, config: Desktop.Config, layoutConfig: LayoutConfig) {
|
||||
this.config = config;
|
||||
this.scrollX = 0;
|
||||
this.dirty = false;
|
||||
@@ -34,7 +34,7 @@ class ScrollView {
|
||||
this.autoAdjustScroll();
|
||||
}
|
||||
|
||||
// calculates ScrollView.Pos that scrolls the column into view
|
||||
// calculates Desktop.Pos that scrolls the column into view
|
||||
public getScrollPosForColumn(column: Column) {
|
||||
const left = column.getLeft();
|
||||
const right = column.getRight();
|
||||
@@ -89,7 +89,7 @@ class ScrollView {
|
||||
}
|
||||
|
||||
private getScrollPos(scrollX: number) {
|
||||
return new ScrollView.Pos(scrollX, this.tilingArea.width);
|
||||
return new Desktop.Pos(scrollX, this.tilingArea.width);
|
||||
}
|
||||
|
||||
public getCurrentScrollPos() {
|
||||
@@ -115,7 +115,7 @@ class ScrollView {
|
||||
}
|
||||
}
|
||||
|
||||
private applyScrollPos(scrollPos: ScrollView.Pos) {
|
||||
private applyScrollPos(scrollPos: Desktop.Pos) {
|
||||
this.setScroll(scrollPos.x, true);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ class ScrollView {
|
||||
}
|
||||
}
|
||||
|
||||
module ScrollView {
|
||||
module Desktop {
|
||||
export type Config = {
|
||||
marginTop: number,
|
||||
marginBottom: number,
|
||||
@@ -1,5 +1,5 @@
|
||||
class Grid {
|
||||
public readonly container: ScrollView;
|
||||
public readonly container: Desktop;
|
||||
public readonly config: LayoutConfig;
|
||||
private readonly columns: LinkedList<Column>;
|
||||
private lastFocusedColumn: Column|null;
|
||||
@@ -7,7 +7,7 @@ class Grid {
|
||||
private userResize: boolean; // is any part of the grid being resized by the user
|
||||
private readonly userResizeFinishedDelayer: Delayer;
|
||||
|
||||
constructor(container: ScrollView, config: LayoutConfig) {
|
||||
constructor(container: Desktop, config: LayoutConfig) {
|
||||
this.container = container;
|
||||
this.config = config;
|
||||
this.columns = new LinkedList();
|
||||
@@ -88,7 +88,7 @@ class Grid {
|
||||
this.width = x - this.config.gapsInnerHorizontal;
|
||||
}
|
||||
|
||||
public getLeftmostVisibleColumn(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
public getLeftmostVisibleColumn(scrollPos: Desktop.Pos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getLeft();
|
||||
for (const column of this.columns.iterator()) {
|
||||
const x = fullyVisible ? column.getLeft() : column.getRight() + (this.config.gapsInnerHorizontal - 1);
|
||||
@@ -99,7 +99,7 @@ class Grid {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getRightmostVisibleColumn(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
public getRightmostVisibleColumn(scrollPos: Desktop.Pos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getRight();
|
||||
let last = null;
|
||||
for (const column of this.columns.iterator()) {
|
||||
@@ -113,7 +113,7 @@ class Grid {
|
||||
return last;
|
||||
}
|
||||
|
||||
public getVisibleColumnsWidth(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
public getVisibleColumnsWidth(scrollPos: Desktop.Pos, fullyVisible: boolean) {
|
||||
let width = 0;
|
||||
let nVisible = 0;
|
||||
for (const column of this.columns.iterator()) {
|
||||
@@ -130,7 +130,7 @@ class Grid {
|
||||
return width;
|
||||
}
|
||||
|
||||
private getLeftOffScreenColumn(scrollPos: ScrollView.Pos) {
|
||||
private getLeftOffScreenColumn(scrollPos: Desktop.Pos) {
|
||||
const leftVisible = this.getLeftmostVisibleColumn(scrollPos, true);
|
||||
if (leftVisible === null) {
|
||||
return null;
|
||||
@@ -138,7 +138,7 @@ class Grid {
|
||||
return this.getPrevColumn(leftVisible);
|
||||
}
|
||||
|
||||
private getRightOffScreenColumn(scrollPos: ScrollView.Pos) {
|
||||
private getRightOffScreenColumn(scrollPos: Desktop.Pos) {
|
||||
const rightVisible = this.getRightmostVisibleColumn(scrollPos, true);
|
||||
if (rightVisible === null) {
|
||||
return null;
|
||||
|
||||
@@ -26,7 +26,7 @@ class WindowRuleEnforcer {
|
||||
const manager = new SignalManager();
|
||||
manager.connect(kwinClient.captionChanged, () => {
|
||||
const shouldTile = enforcer.shouldTile(kwinClient);
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (shouldTile) {
|
||||
clientManager.tileClient(kwinClient);
|
||||
} else {
|
||||
|
||||
@@ -11,31 +11,31 @@ function initWorkspaceSignalHandlers(world: World) {
|
||||
kwinClient.activities = [workspace.currentActivity];
|
||||
}
|
||||
}
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.addClient(kwinClient)
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientRemoved, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.removeClient(kwinClient, true);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientMinimized, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.minimizeClient(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientUnminimized, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.unminimizeClient(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientMaximizeSet, (kwinClient: AbstractClient, horizontally: boolean, vertically: boolean) => {
|
||||
world.doIfTiled(kwinClient, false, (world, svm, window, column, grid) => {
|
||||
world.doIfTiled(kwinClient, false, (world, desktopManager, window, column, grid) => {
|
||||
window.onMaximizedChanged(horizontally, vertically);
|
||||
});
|
||||
});
|
||||
@@ -44,13 +44,13 @@ function initWorkspaceSignalHandlers(world: World) {
|
||||
if (kwinClient === null) {
|
||||
return;
|
||||
}
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.onClientFocused(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientFullScreenSet, (kwinClient: X11Client, fullScreen: boolean, user: boolean) => {
|
||||
world.doIfTiled(kwinClient, false, (clientManager, svm, window, column, grid) => {
|
||||
world.doIfTiled(kwinClient, false, (clientManager, desktopManager, window, column, grid) => {
|
||||
window.onFullScreenChanged(fullScreen);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class ClientManager {
|
||||
private readonly world: World;
|
||||
private readonly scrollViewManager: ScrollViewManager;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
private readonly clientMap: Map<AbstractClient, ClientWrapper>;
|
||||
private lastFocusedClient: AbstractClient|null;
|
||||
private readonly windowRuleEnforcer: WindowRuleEnforcer;
|
||||
|
||||
constructor(config: Config, world: World, svm: ScrollViewManager) {
|
||||
constructor(config: Config, world: World, desktopManager: DesktopManager) {
|
||||
this.world = world;
|
||||
this.scrollViewManager = svm;
|
||||
this.desktopManager = desktopManager;
|
||||
this.clientMap = new Map();
|
||||
this.lastFocusedClient = null;
|
||||
|
||||
@@ -33,7 +33,7 @@ class ClientManager {
|
||||
if (kwinClient.dock) {
|
||||
client.stateManager.setState(new ClientStateDocked(this.world, kwinClient), false);
|
||||
} else if (this.windowRuleEnforcer.shouldTile(kwinClient)) {
|
||||
const grid = this.scrollViewManager.getForClient(client.kwinClient).grid;
|
||||
const grid = this.desktopManager.getForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(new ClientStateTiled(this.world, client, grid), false);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class ClientManager {
|
||||
return;
|
||||
}
|
||||
if (client.stateManager.getState() instanceof ClientStateTiledMinimized) {
|
||||
const grid = this.scrollViewManager.getForClient(client.kwinClient).grid;
|
||||
const grid = this.desktopManager.getForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(new ClientStateTiled(this.world, client, grid), false);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class ClientManager {
|
||||
if (client.stateManager.getState() instanceof ClientStateTiled) {
|
||||
return;
|
||||
}
|
||||
const grid = this.scrollViewManager.getForClient(client.kwinClient).grid;
|
||||
const grid = this.desktopManager.getForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(new ClientStateTiled(this.world, client, grid), false);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class ClientManager {
|
||||
const clientState = client.stateManager.getState();
|
||||
if (clientState instanceof ClientStateFloating && Clients.canTileEver(kwinClient)) {
|
||||
Clients.makeTileable(kwinClient);
|
||||
const grid = this.scrollViewManager.getForClient(client.kwinClient).grid;
|
||||
const grid = this.desktopManager.getForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(new ClientStateTiled(this.world, client, grid), false);
|
||||
} else if (clientState instanceof ClientStateTiled) {
|
||||
client.stateManager.setState(new ClientStateFloating(), false);
|
||||
|
||||
@@ -29,30 +29,30 @@ class ClientStateTiled {
|
||||
const manager = new SignalManager();
|
||||
|
||||
manager.connect(kwinClient.desktopChanged, () => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (kwinClient.desktop === -1) {
|
||||
// windows on all desktops are not supported
|
||||
clientManager.untileClient(kwinClient);
|
||||
return;
|
||||
}
|
||||
ClientStateTiled.moveWindowToCorrectGrid(svm, window);
|
||||
ClientStateTiled.moveWindowToCorrectGrid(desktopManager, window);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.activitiesChanged, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (kwinClient.activities.length !== 1) {
|
||||
// windows on multiple activities are not supported
|
||||
clientManager.untileClient(kwinClient);
|
||||
return;
|
||||
}
|
||||
ClientStateTiled.moveWindowToCorrectGrid(svm, window);
|
||||
ClientStateTiled.moveWindowToCorrectGrid(desktopManager, window);
|
||||
});
|
||||
})
|
||||
|
||||
let lastResize = false;
|
||||
manager.connect(kwinClient.moveResizedChanged, () => {
|
||||
world.do((clientManager, svm) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (world.untileOnDrag && kwinClient.move) {
|
||||
clientManager.untileClient(kwinClient);
|
||||
return;
|
||||
@@ -79,12 +79,12 @@ class ClientStateTiled {
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: TopLevel, oldGeometry: QRect) => {
|
||||
world.do((clientManager, svm) => {
|
||||
const scrollView = window.column.grid.container;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const desktop = window.column.grid.container;
|
||||
if (kwinClient.resize) {
|
||||
window.onUserResize(oldGeometry, !cursorChangedAfterResizeStart);
|
||||
} else {
|
||||
const maximized = rectEqual(kwinClient.frameGeometry, scrollView.clientArea);
|
||||
const maximized = rectEqual(kwinClient.frameGeometry, desktop.clientArea);
|
||||
if (!client.isManipulatingGeometry() && !kwinClient.fullScreen && !maximized) {
|
||||
window.onProgrammaticResize(oldGeometry);
|
||||
}
|
||||
@@ -95,11 +95,11 @@ class ClientStateTiled {
|
||||
return manager;
|
||||
}
|
||||
|
||||
private static moveWindowToCorrectGrid(svm: ScrollViewManager, window: Window) {
|
||||
private static moveWindowToCorrectGrid(desktopManager: DesktopManager, window: Window) {
|
||||
const kwinClient = window.client.kwinClient;
|
||||
|
||||
const oldGrid = window.column.grid;
|
||||
const newGrid = svm.getForClient(kwinClient).grid;
|
||||
const newGrid = desktopManager.getForClient(kwinClient).grid;
|
||||
if (oldGrid === newGrid) {
|
||||
// window already on the correct grid
|
||||
return;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class ScrollViewManager {
|
||||
private readonly config: ScrollView.Config;
|
||||
class DesktopManager {
|
||||
private readonly config: Desktop.Config;
|
||||
public readonly layoutConfig: LayoutConfig;
|
||||
private readonly scrollViewsPerActivity: Map<string, ScrollView[]>;
|
||||
private readonly desktopsPerActivity: Map<string, Desktop[]>;
|
||||
private nVirtualDesktops: number;
|
||||
|
||||
constructor(config: ScrollView.Config, layoutConfig: LayoutConfig, currentActivity: string) {
|
||||
constructor(config: Desktop.Config, layoutConfig: LayoutConfig, currentActivity: string) {
|
||||
this.config = config;
|
||||
this.layoutConfig = layoutConfig;
|
||||
this.scrollViewsPerActivity = new Map();
|
||||
this.desktopsPerActivity = new Map();
|
||||
this.nVirtualDesktops = 0;
|
||||
this.update()
|
||||
this.addActivity(currentActivity);
|
||||
@@ -22,10 +22,10 @@ class ScrollViewManager {
|
||||
if (desktopIndex >= this.nVirtualDesktops || this.nVirtualDesktops < 0) {
|
||||
throw new Error("invalid desktop number: " + String(desktopNumber));
|
||||
}
|
||||
if (!this.scrollViewsPerActivity.has(activity)) {
|
||||
if (!this.desktopsPerActivity.has(activity)) {
|
||||
this.addActivity(activity);
|
||||
}
|
||||
return this.scrollViewsPerActivity.get(activity)![desktopIndex];
|
||||
return this.desktopsPerActivity.get(activity)![desktopIndex];
|
||||
}
|
||||
|
||||
public getCurrent() {
|
||||
@@ -51,55 +51,55 @@ class ScrollViewManager {
|
||||
}
|
||||
|
||||
private addDesktopsToActivities(n: number) {
|
||||
for (const scrollViews of this.scrollViewsPerActivity.values()) {
|
||||
this.addDesktops(scrollViews, n);
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
this.addDesktops(desktops, n);
|
||||
}
|
||||
}
|
||||
|
||||
private addDesktops(scrollViews: ScrollView[], n: number) {
|
||||
const nStart = scrollViews.length;
|
||||
private addDesktops(desktops: Desktop[], n: number) {
|
||||
const nStart = desktops.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const desktopNumber = nStart + i + 1;
|
||||
scrollViews.push(new ScrollView(desktopNumber, this.config, this.layoutConfig));
|
||||
desktops.push(new Desktop(desktopNumber, this.config, this.layoutConfig));
|
||||
}
|
||||
}
|
||||
|
||||
private removeDesktopsFromActivities(n: number) {
|
||||
const lastRemainingDesktopIndex = this.nVirtualDesktops - n - 1;
|
||||
for (const scrollViews of this.scrollViewsPerActivity.values()) {
|
||||
const targetScrollView = scrollViews[lastRemainingDesktopIndex];
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
const targetDesktop = desktops[lastRemainingDesktopIndex];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const removedScrollView = scrollViews.pop()!;
|
||||
removedScrollView.grid.evacuate(targetScrollView.grid);
|
||||
const removedDesktop = desktops.pop()!;
|
||||
removedDesktop.grid.evacuate(targetDesktop.grid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private addActivity(activity: string) {
|
||||
const scrollViews: ScrollView[] = [];
|
||||
this.addDesktops(scrollViews, this.nVirtualDesktops);
|
||||
this.scrollViewsPerActivity.set(activity, scrollViews);
|
||||
const desktops: Desktop[] = [];
|
||||
this.addDesktops(desktops, this.nVirtualDesktops);
|
||||
this.desktopsPerActivity.set(activity, desktops);
|
||||
}
|
||||
|
||||
private removeActivity(activity: string) {
|
||||
const removedScrollViews = this.scrollViewsPerActivity.get(activity)!;
|
||||
this.scrollViewsPerActivity.delete(activity);
|
||||
const targetActivityScrollViews = this.scrollViewsPerActivity.values().next().value;
|
||||
for (let i = 0; i < removedScrollViews.length; i++) {
|
||||
removedScrollViews[i].grid.evacuate(targetActivityScrollViews[i]);
|
||||
const removedDesktops = this.desktopsPerActivity.get(activity)!;
|
||||
this.desktopsPerActivity.delete(activity);
|
||||
const targetActivityDesktops = this.desktopsPerActivity.values().next().value;
|
||||
for (let i = 0; i < removedDesktops.length; i++) {
|
||||
removedDesktops[i].grid.evacuate(targetActivityDesktops[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
for (const scrollView of this.scrollViews()) {
|
||||
scrollView.destroy();
|
||||
for (const desktop of this.desktops()) {
|
||||
desktop.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public *scrollViews() {
|
||||
for (const scrollViews of this.scrollViewsPerActivity.values()) {
|
||||
for (const scrollView of scrollViews) {
|
||||
yield scrollView;
|
||||
public *desktops() {
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
for (const desktop of desktops) {
|
||||
yield desktop;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class World {
|
||||
public readonly untileOnDrag: boolean;
|
||||
private readonly scrollViewManager: ScrollViewManager;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
public readonly clientManager: ClientManager;
|
||||
private readonly workspaceSignalManager: SignalManager;
|
||||
private readonly screenResizedDelayer: Delayer;
|
||||
@@ -11,14 +11,14 @@ class World {
|
||||
|
||||
this.screenResizedDelayer = new Delayer(1000, () => {
|
||||
// this delay ensures that docks get taken into account by `workspace.clientArea`
|
||||
const gridManager = this.scrollViewManager; // workaround for bug in Qt5's JS engine
|
||||
for (const scrollView of gridManager.scrollViews()) {
|
||||
scrollView.onLayoutChanged();
|
||||
const gridManager = this.desktopManager; // workaround for bug in Qt5's JS engine
|
||||
for (const desktop of gridManager.desktops()) {
|
||||
desktop.onLayoutChanged();
|
||||
}
|
||||
this.update();
|
||||
});
|
||||
|
||||
this.scrollViewManager = new ScrollViewManager(
|
||||
this.desktopManager = new DesktopManager(
|
||||
{
|
||||
marginTop: config.gapsOuterTop,
|
||||
marginBottom: config.gapsOuterBottom,
|
||||
@@ -29,7 +29,7 @@ class World {
|
||||
config,
|
||||
workspace.currentActivity,
|
||||
);
|
||||
this.clientManager = new ClientManager(config, this, this.scrollViewManager);
|
||||
this.clientManager = new ClientManager(config, this, this.desktopManager);
|
||||
this.addExistingClients();
|
||||
this.update();
|
||||
}
|
||||
@@ -43,22 +43,22 @@ class World {
|
||||
}
|
||||
|
||||
public updateDesktops() {
|
||||
this.scrollViewManager.update();
|
||||
this.desktopManager.update();
|
||||
}
|
||||
|
||||
public update() {
|
||||
this.scrollViewManager.getCurrent().arrange();
|
||||
this.desktopManager.getCurrent().arrange();
|
||||
}
|
||||
|
||||
public do(f: (clientManager: ClientManager, svm: ScrollViewManager) => void) {
|
||||
f(this.clientManager, this.scrollViewManager);
|
||||
public do(f: (clientManager: ClientManager, desktopManager: DesktopManager) => void) {
|
||||
f(this.clientManager, this.desktopManager);
|
||||
this.update();
|
||||
}
|
||||
|
||||
public doIfTiled(
|
||||
kwinClient: AbstractClient,
|
||||
followTransient: boolean,
|
||||
f: (clientManager: ClientManager, svm: ScrollViewManager, window: Window, column: Column, grid: Grid) => void,
|
||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||
) {
|
||||
const window = this.clientManager.findTiledWindow(kwinClient, followTransient);
|
||||
if (window === null) {
|
||||
@@ -66,13 +66,13 @@ class World {
|
||||
}
|
||||
const column = window.column;
|
||||
const grid = column.grid;
|
||||
f(this.clientManager, this.scrollViewManager, window, column, grid);
|
||||
f(this.clientManager, this.desktopManager, window, column, grid);
|
||||
this.update();
|
||||
}
|
||||
|
||||
public doIfTiledFocused(
|
||||
followTransient: boolean,
|
||||
f: (clientManager: ClientManager, svm: ScrollViewManager, window: Window, column: Column, grid: Grid) => void,
|
||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||
) {
|
||||
this.doIfTiled(workspace.activeClient, followTransient, f);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class World {
|
||||
public destroy() {
|
||||
this.workspaceSignalManager.destroy();
|
||||
this.clientManager.destroy();
|
||||
this.scrollViewManager.destroy();
|
||||
this.desktopManager.destroy();
|
||||
}
|
||||
|
||||
public onScreenResized() {
|
||||
|
||||
Reference in New Issue
Block a user