Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: use correct min/max func and start val for finding closest window
Browse files Browse the repository at this point in the history
  • Loading branch information
Daxtorim authored and Mikhail Zolotukhin committed Dec 5, 2021
1 parent 1015120 commit 2548aa5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/kwinscript/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,18 +665,21 @@ export class EngineImpl implements Engine {
windowArray: EngineWindow[],
dir: Direction
): number {
return windowArray.reduce((prevValue, window): number => {
switch (dir) {
case "up":
return Math.min(window.geometry.maxY, prevValue);
case "down":
return Math.max(window.geometry.y, prevValue);
case "left":
return Math.min(window.geometry.maxX, prevValue);
case "right":
return Math.max(window.geometry.x, prevValue);
}
}, Infinity);
return windowArray.reduce(
(prevValue, window): number => {
switch (dir) {
case "up":
return Math.max(window.geometry.maxY, prevValue);
case "down":
return Math.min(window.geometry.y, prevValue);
case "left":
return Math.max(window.geometry.maxX, prevValue);
case "right":
return Math.min(window.geometry.x, prevValue);
}
},
dir === "up" || dir === "left" ? 0 : Infinity
);
}

private getClosestRelativeWindow(
Expand Down

0 comments on commit 2548aa5

Please sign in to comment.