mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-08-14 18:40:35 +03:00
refactor(window_store): rename query methods
This commit is contained in:
parent
9e0029aa48
commit
48249751ff
@ -221,7 +221,7 @@ export class ControllerImpl implements Controller {
|
||||
/* move window to next surface if the current surface is "full" */
|
||||
if (window.tileable) {
|
||||
const srf = this.currentSurface;
|
||||
const tiles = this.engine.windows.getVisibleTiles(srf);
|
||||
const tiles = this.engine.windows.visibleTiledWindowsOn(srf);
|
||||
const layoutCapacity = this.engine.layouts.getCurrentLayout(srf).capacity;
|
||||
if (layoutCapacity !== undefined && tiles.length > layoutCapacity) {
|
||||
const nextSurface = this.currentSurface.next();
|
||||
@ -270,7 +270,9 @@ export class ControllerImpl implements Controller {
|
||||
|
||||
/* swap window by dragging */
|
||||
if (window.state === WindowState.Tiled) {
|
||||
const tiles = this.engine.windows.getVisibleTiles(this.currentSurface);
|
||||
const tiles = this.engine.windows.visibleTiledWindowsOn(
|
||||
this.currentSurface
|
||||
);
|
||||
const windowCenter = window.actualGeometry.center;
|
||||
|
||||
const targets = tiles.filter(
|
||||
@ -359,7 +361,9 @@ export class ControllerImpl implements Controller {
|
||||
// Minimize other windows if Monocle and config.monocleMinimizeRest
|
||||
if (
|
||||
this.engine.isLayoutMonocleAndMinimizeRest() &&
|
||||
this.engine.windows.getVisibleTiles(window.surface).includes(window)
|
||||
this.engine.windows
|
||||
.visibleTiledWindowsOn(window.surface)
|
||||
.includes(window)
|
||||
) {
|
||||
/* If a window hasn't been focused in this layout yet, ensure its geometry
|
||||
* gets maximized.
|
||||
@ -368,7 +372,7 @@ export class ControllerImpl implements Controller {
|
||||
.currentLayoutOnCurrentSurface()
|
||||
.apply(
|
||||
this,
|
||||
this.engine.windows.getAllTileables(window.surface),
|
||||
this.engine.windows.tileableWindowsOn(window.surface),
|
||||
window.surface.workingArea
|
||||
);
|
||||
|
||||
|
@ -58,8 +58,8 @@ describe("arrangeScreen", () => {
|
||||
});
|
||||
|
||||
engine.windows = createMock<WindowStore>({
|
||||
getVisibleWindows: () => [window1, window2],
|
||||
getVisibleTileables: () => [],
|
||||
visibleWindowsOn: () => [window1, window2],
|
||||
visibleTileableWindowsOn: () => [],
|
||||
});
|
||||
|
||||
engine.layouts = createMock<LayoutStore>({
|
||||
|
@ -190,7 +190,7 @@ export class EngineImpl implements Engine {
|
||||
this.config.screenGapTop,
|
||||
this.config.screenGapBottom
|
||||
);
|
||||
const tiles = this.windows.getVisibleTiles(srf);
|
||||
const tiles = this.windows.visibleTiledWindowsOn(srf);
|
||||
layout.adjust(area, tiles, basis, basis.geometryDelta);
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ export class EngineImpl implements Engine {
|
||||
if (dir === "east") {
|
||||
const maxX = basis.geometry.maxX;
|
||||
const easternNeighbor = this.windows
|
||||
.getVisibleTiles(srf)
|
||||
.visibleTiledWindowsOn(srf)
|
||||
.filter((tile) => tile.geometry.x >= maxX);
|
||||
if (easternNeighbor.length === 0) {
|
||||
dir = "west";
|
||||
@ -248,7 +248,7 @@ export class EngineImpl implements Engine {
|
||||
} else if (dir === "south") {
|
||||
const maxY = basis.geometry.maxY;
|
||||
const southernNeighbor = this.windows
|
||||
.getVisibleTiles(srf)
|
||||
.visibleTiledWindowsOn(srf)
|
||||
.filter((tile) => tile.geometry.y >= maxY);
|
||||
if (southernNeighbor.length === 0) {
|
||||
dir = "north";
|
||||
@ -284,7 +284,12 @@ export class EngineImpl implements Engine {
|
||||
this.config.screenGapTop,
|
||||
this.config.screenGapBottom
|
||||
);
|
||||
layout.adjust(area, this.windows.getVisibleTileables(srf), basis, delta);
|
||||
layout.adjust(
|
||||
area,
|
||||
this.windows.visibleTileableWindowsOn(srf),
|
||||
basis,
|
||||
delta
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +325,7 @@ export class EngineImpl implements Engine {
|
||||
const workingArea = screenSurface.workingArea;
|
||||
const tilingArea = this.getTilingArea(workingArea, layout);
|
||||
|
||||
const visibleWindows = this.windows.getVisibleWindows(screenSurface);
|
||||
const visibleWindows = this.windows.visibleWindowsOn(screenSurface);
|
||||
this.log.log([
|
||||
"arrangeScreen",
|
||||
{
|
||||
@ -337,7 +342,8 @@ export class EngineImpl implements Engine {
|
||||
}
|
||||
});
|
||||
|
||||
const tileableWindows = this.windows.getVisibleTileables(screenSurface);
|
||||
const tileableWindows =
|
||||
this.windows.visibleTileableWindowsOn(screenSurface);
|
||||
|
||||
// Maximize sole tile if enabled or apply the current layout as expected
|
||||
if (this.config.maximizeSoleTile && tileableWindows.length === 1) {
|
||||
@ -412,9 +418,9 @@ export class EngineImpl implements Engine {
|
||||
let windows;
|
||||
|
||||
if (includeHidden) {
|
||||
windows = this.windows.getAllWindows(this.controller.currentSurface);
|
||||
windows = this.windows.allWindowsOn(this.controller.currentSurface);
|
||||
} else {
|
||||
windows = this.windows.getVisibleWindows(this.controller.currentSurface);
|
||||
windows = this.windows.visibleWindowsOn(this.controller.currentSurface);
|
||||
}
|
||||
|
||||
if (windows.length === 0) {
|
||||
@ -446,7 +452,7 @@ export class EngineImpl implements Engine {
|
||||
|
||||
/* if no current window, select the first tile. */
|
||||
if (window === null) {
|
||||
const tiles = this.windows.getVisibleTiles(
|
||||
const tiles = this.windows.visibleTiledWindowsOn(
|
||||
this.controller.currentSurface
|
||||
);
|
||||
if (tiles.length > 1) {
|
||||
@ -463,7 +469,7 @@ export class EngineImpl implements Engine {
|
||||
|
||||
public swapOrder(window: EngineWindow, step: Step): void {
|
||||
const srf = window.surface;
|
||||
const visibles = this.windows.getVisibleWindows(srf);
|
||||
const visibles = this.windows.visibleWindowsOn(srf);
|
||||
if (visibles.length < 2) {
|
||||
return;
|
||||
}
|
||||
@ -482,7 +488,7 @@ export class EngineImpl implements Engine {
|
||||
const window = this.controller.currentWindow;
|
||||
if (window === null) {
|
||||
/* if no current window, select the first tile. */
|
||||
const tiles = this.windows.getVisibleTiles(
|
||||
const tiles = this.windows.visibleTiledWindowsOn(
|
||||
this.controller.currentSurface
|
||||
);
|
||||
if (tiles.length > 1) {
|
||||
@ -591,11 +597,11 @@ export class EngineImpl implements Engine {
|
||||
}
|
||||
|
||||
public minimizeOthers(window: EngineWindow): void {
|
||||
for (const tile of this.windows.getVisibleTiles(window.surface)) {
|
||||
for (const tile of this.windows.visibleTiledWindowsOn(window.surface)) {
|
||||
if (
|
||||
tile.screen == window.screen &&
|
||||
tile.id !== window.id &&
|
||||
this.windows.getVisibleTiles(window.surface).includes(window)
|
||||
this.windows.visibleTiledWindowsOn(window.surface).includes(window)
|
||||
) {
|
||||
tile.minimized = true;
|
||||
} else {
|
||||
@ -639,7 +645,7 @@ export class EngineImpl implements Engine {
|
||||
}
|
||||
|
||||
const candidates = this.windows
|
||||
.getVisibleTiles(this.controller.currentSurface)
|
||||
.visibleTiledWindowsOn(this.controller.currentSurface)
|
||||
.filter(
|
||||
vertical
|
||||
? (tile): boolean => tile.geometry.y * sign > basis.geometry.y * sign
|
||||
|
@ -49,8 +49,6 @@ export default class WindowStore {
|
||||
this.list[betaIndex] = alpha;
|
||||
}
|
||||
|
||||
//#region Storage Operation
|
||||
|
||||
public get length(): number {
|
||||
return this.list.length;
|
||||
}
|
||||
@ -77,39 +75,42 @@ export default class WindowStore {
|
||||
public unshift(window: EngineWindow): void {
|
||||
this.list.unshift(window);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region Querying Windows
|
||||
|
||||
/** Returns all visible windows on the given surface. */
|
||||
public getVisibleWindows(srf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.visibleOn(srf));
|
||||
/**
|
||||
* Returns all visible windows on the given surface.
|
||||
*/
|
||||
public visibleWindowsOn(surf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.visibleOn(surf));
|
||||
}
|
||||
|
||||
/** Return all visible "Tile" windows on the given surface. */
|
||||
public getVisibleTiles(srf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.tiled && win.visibleOn(srf));
|
||||
/**
|
||||
* Return all visible "Tile" windows on the given surface.
|
||||
*/
|
||||
public visibleTiledWindowsOn(surf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.tiled && win.visibleOn(surf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible "tileable" windows on the given surface
|
||||
* @see Window#tileable
|
||||
*/
|
||||
public getVisibleTileables(srf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.tileable && win.visibleOn(srf));
|
||||
public visibleTileableWindowsOn(surf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.tileable && win.visibleOn(surf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all "tileable" windows on the given surface, including hidden
|
||||
*/
|
||||
public getAllTileables(srf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.tileable && win.surface.id === srf.id);
|
||||
public tileableWindowsOn(surf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter(
|
||||
(win) => win.tileable && win.surface.id === surf.id
|
||||
);
|
||||
}
|
||||
|
||||
/** Return all windows on this surface, including minimized windows */
|
||||
public getAllWindows(srf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.surface.id === srf.id);
|
||||
/**
|
||||
* Return all windows on this surface, including minimized windows
|
||||
*/
|
||||
public allWindowsOn(surf: DriverSurface): EngineWindow[] {
|
||||
return this.list.filter((win) => win.surface.id === surf.id);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user