Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/web/src/lib/windowControlsOverlay.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { useSyncExternalStore } from "react";

import { isWindowsPlatform } from "./utils";
import { isElectron } from "~/env";

import { isMacPlatform, isWindowsPlatform } from "./utils";

const WCO_CLASS_NAME = "wco";
const ELECTRON_CLASS_NAME = "electron";
const ELECTRON_WINDOWS_CLASS_NAME = "electron-windows";
// The workspace topbar the desktop app centers the traffic lights in. macOS has
// no overlay API to measure, and the lights stay inside it at any zoom level.
const MACOS_TITLEBAR_HEIGHT = 52;

interface WindowControlsOverlayLike {
readonly visible: boolean;
Expand Down Expand Up @@ -53,6 +58,7 @@ function subscribeTitlebarArea(listener: () => void): () => void {
}

function getNativeTitlebarHeight(): number {
if (isElectron && isMacPlatform(navigator.platform)) return MACOS_TITLEBAR_HEIGHT;
const overlay = getWindowControlsOverlay();
return overlay?.visible ? overlay.getTitlebarAreaRect().bottom : 0;
}
Expand Down
Loading