(appId: number)
| 46 | } |
| 47 | |
| 48 | export function openWindow(appId: number): void { |
| 49 | const existing = windows.find((w) => w.appId === appId); |
| 50 | if (existing) { |
| 51 | // Focus existing window |
| 52 | existing.zIndex = ++nextZ; |
| 53 | existing.minimized = false; |
| 54 | windows = [...windows]; |
| 55 | notify(); |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | const size = getAppDefaultSize(appId); |
| 60 | const offset = (offsetCounter++ % 5) * 30; |
| 61 | |
| 62 | const win: WindowState = { |
| 63 | appId, |
| 64 | title: getAppDisplayName(appId), |
| 65 | x: 80 + offset, |
| 66 | y: 40 + offset, |
| 67 | width: size.width, |
| 68 | height: size.height, |
| 69 | zIndex: ++nextZ, |
| 70 | minimized: false, |
| 71 | }; |
| 72 | |
| 73 | windows = [...windows, win]; |
| 74 | notify(); |
| 75 | } |
| 76 | |
| 77 | export function closeWindow(appId: number): void { |
| 78 | windows = windows.filter((w) => w.appId !== appId); |
no test coverage detected