eb52328857
Glass was macOS-only because it rode setVibrancy. Windows 11 22H2 has a first-party equivalent in setBackgroundMaterial, so the mode now resolves its backing per platform instead of per-OS-check: macOS keeps vibrancy, Windows 11 gets DWM acrylic / tabbed / mica, and everything older stays on Clear. No third-party native addon. Two Windows-specific details the mapping has to respect. DWM only paints the client area of a transparent window (electron#49443), so glass-capable Windows chat windows are born transparent with the opaque themed backgroundColor covering them while glass is off — a live Clear/Glass toggle then needs no window recreate. And Windows exposes three backdrops for four frost rungs, so the two heaviest both resolve to mica; the mapping stays total so a frost saved on a Mac still renders. Glass support is computed once from os.release() and shared: main uses it for the persisted default and every window, preload publishes it to the renderer so the UI can't offer a mode the window can't back.
20 lines
862 B
TypeScript
20 lines
862 B
TypeScript
/**
|
|
* Platform detection for the renderer.
|
|
*
|
|
* The renderer has no `process.platform`, and several surfaces need to know
|
|
* which OS they're on — keybind glyphs, terminal shortcuts, and glass. One
|
|
* definition so they can't disagree.
|
|
*
|
|
* Win10 vs Win11 is not visible here (both report NT 10.0). The real glass
|
|
* gate is `hermesDesktop.glassSupported`, which main/preload compute from
|
|
* `os.release()`.
|
|
*/
|
|
|
|
export const isMacPlatform = (): boolean =>
|
|
typeof navigator !== 'undefined' && /mac/i.test(navigator.platform || navigator.userAgent || '')
|
|
|
|
// Not `/win/i` — that matches the substring inside `darwin`, which is jsdom's
|
|
// default userAgent. Win32 / Windows NT are the real tokens.
|
|
export const isWindowsPlatform = (): boolean =>
|
|
typeof navigator !== 'undefined' && /win32|windows/i.test(navigator.platform || navigator.userAgent || '')
|