| ... | @@ -1,10 +1,15 @@ | ... | @@ -1,10 +1,15 @@ |
| 1 | import { useSyncExternalStore } from "react"; | 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 | const WCO_CLASS_NAME = "wco"; | 7 | const WCO_CLASS_NAME = "wco"; |
| 6 | const ELECTRON_CLASS_NAME = "electron"; | 8 | const ELECTRON_CLASS_NAME = "electron"; |
| 7 | const ELECTRON_WINDOWS_CLASS_NAME = "electron-windows"; | 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 | interface WindowControlsOverlayLike { | 14 | interface WindowControlsOverlayLike { |
| 10 | readonly visible: boolean; | 15 | readonly visible: boolean; |
| ... | @@ -53,6 +58,7 @@ function subscribeTitlebarArea(listener: () => void): () => void { | ... | @@ -53,6 +58,7 @@ function subscribeTitlebarArea(listener: () => void): () => void { |
| 53 | } | 58 | } |
| 54 | | 59 | |
| 55 | function getNativeTitlebarHeight(): number { | 60 | function getNativeTitlebarHeight(): number { |
| | 61 | if (isElectron && isMacPlatform(navigator.platform)) return MACOS_TITLEBAR_HEIGHT; |
| 56 | const overlay = getWindowControlsOverlay(); | 62 | const overlay = getWindowControlsOverlay(); |
| 57 | return overlay?.visible ? overlay.getTitlebarAreaRect().bottom : 0; | 63 | return overlay?.visible ? overlay.getTitlebarAreaRect().bottom : 0; |
| 58 | } | 64 | } |