Skip to content

Commit

Permalink
Only restore visible windows
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinBrett committed Oct 8, 2023
1 parent 61ae37b commit b8d2461
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const sendMouseClick = (target: HTMLElement, count = 1): void => {
sendMouseClick(target, count - 1);
};

let visibleWindows: string[] = [];

export const toggleShowDesktop = (
processes: Processes,
stackOrder: string[],
Expand All @@ -57,12 +59,18 @@ export const toggleShowDesktop = (
const restoreWindows =
stackOrder.length > 0 &&
!stackOrder.some((pid) => !processes[pid]?.minimized);
const allWindows = restoreWindows ? [...stackOrder].reverse() : stackOrder;

(restoreWindows ? [...stackOrder].reverse() : stackOrder).forEach(
(pid) =>
(restoreWindows || (!restoreWindows && !processes[pid]?.minimized)) &&
minimize(pid)
);
if (!restoreWindows) visibleWindows = [];

allWindows.forEach((pid) => {
if (restoreWindows) {
if (visibleWindows.includes(pid)) minimize(pid);
} else if (!processes[pid]?.minimized) {
visibleWindows.push(pid);
minimize(pid);
}
});

if (restoreWindows) {
requestAnimationFrame(
Expand Down

0 comments on commit b8d2461

Please sign in to comment.