| 934 | } |
| 935 | |
| 936 | function moveWindowToDisplay(win: WaveBrowserWindow, targetDisplay: Electron.Display) { |
| 937 | if (!win || !targetDisplay || win.isDestroyed()) { |
| 938 | return; |
| 939 | } |
| 940 | const curBounds = win.getBounds(); |
| 941 | const sourceDisplay = screen.getDisplayMatching(curBounds); |
| 942 | if (sourceDisplay.id === targetDisplay.id) { |
| 943 | return; |
| 944 | } |
| 945 | |
| 946 | const sourceArea = sourceDisplay.workArea; |
| 947 | const targetArea = targetDisplay.workArea; |
| 948 | const nextHeight = Math.min(curBounds.height, targetArea.height); |
| 949 | const nextWidth = Math.min(curBounds.width, targetArea.width); |
| 950 | const maxXOffset = Math.max(0, targetArea.width - nextWidth); |
| 951 | const maxYOffset = Math.max(0, targetArea.height - nextHeight); |
| 952 | const sourceXOffset = curBounds.x - sourceArea.x; |
| 953 | const sourceYOffset = curBounds.y - sourceArea.y; |
| 954 | const nextX = targetArea.x + Math.min(Math.max(sourceXOffset, 0), maxXOffset); |
| 955 | const nextY = targetArea.y + Math.min(Math.max(sourceYOffset, 0), maxYOffset); |
| 956 | |
| 957 | win.setBounds({ ...curBounds, x: nextX, y: nextY, width: nextWidth, height: nextHeight }); |
| 958 | } |
| 959 | |
| 960 | const FullscreenTransitionTimeoutMs = 2000; |
| 961 | |