| ... | ... | @@ -1,10 +1,15 @@ |
| 1 | 1 | import { useSyncExternalStore } from "react"; |
| 2 | 2 | |
| 3 | | import { isWindowsPlatform } from "./utils"; |
| 3 | import { isElectron } from "~/env"; |
| 4 | |
| 5 | import { isMacPlatform, isWindowsPlatform } from "./utils"; |
| 4 | 6 | |
| 5 | 7 | const WCO_CLASS_NAME = "wco"; |
| 6 | 8 | const ELECTRON_CLASS_NAME = "electron"; |
| 7 | 9 | const ELECTRON_WINDOWS_CLASS_NAME = "electron-windows"; |
| 10 | // The workspace topbar the desktop app centers the traffic lights in. macOS has |
| 11 | // no overlay API to measure, and the lights stay inside it at any zoom level. |
| 12 | const MACOS_TITLEBAR_HEIGHT = 52; |
| 8 | 13 | |
| 9 | 14 | interface WindowControlsOverlayLike { |
| 10 | 15 | readonly visible: boolean; |
| ... | ... | @@ -53,6 +58,7 @@ function subscribeTitlebarArea(listener: () => void): () => void { |
| 53 | 58 | } |
| 54 | 59 | |
| 55 | 60 | function getNativeTitlebarHeight(): number { |
| 61 | if (isElectron && isMacPlatform(navigator.platform)) return MACOS_TITLEBAR_HEIGHT; |
| 56 | 62 | const overlay = getWindowControlsOverlay(); |
| 57 | 63 | return overlay?.visible ? overlay.getTitlebarAreaRect().bottom : 0; |
| 58 | 64 | } |