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