diff --git a/README.md b/README.md index a1208d8..0e2c60c 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,56 @@ On Windows 10, `[options]` should be a String or an Object. If true, log will be printed to console. +## Known Issues + +* Known issue on Windows 11 - opening web developer tools will disable the acrylic effect. + +## Mac Support + +For cross-platform projects for Windows and Mac you need to use the default `electron` BrowserWindow for Mac environments. Here's an example of how to do this in TypeScript: + +```typescript +import os from 'os'; +import { + BrowserWindow as MacBrowserWindow, + BrowserWindowConstructorOptions, +} from 'electron'; +import { + AcrylicBrowserWindowConstructorOptions, + BrowserWindow as WindowsBrowserWindow +} from 'electron-acrylic-window'; + +const isWindows = os.platform() === 'win32'; + +let mainWindow: MacBrowserWindow | WindowsBrowserWindow | null = null; + +app.on('ready', function () { + const params: BrowserWindowConstructorOptions = { + width: 800, + height: 600, + autoHideMenuBar: true, + ... + }; + const macParams: BrowserWindowConstructorOptions = { + ...params, + backgroundColor: '#00000000', + vibrancy: 'under-window', + visualEffectState: 'active' + }; + const winParams: AcrylicBrowserWindowConstructorOptions = { + ...params, + vibrancy: { + effect: 'acrylic' + } + }; + mainWindow = isWindows + ? new WindowsBrowserWindow(winParams) + : new MacBrowserWindow(macParams); +}); + + +``` + ## Demo To run the demo Electron application, clone this repository, install the dependencies and run the test script: diff --git a/package.json b/package.json index fa43eab..0c79e5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron-acrylic-window", - "version": "0.5.11", + "version": "0.5.12", "description": "Add vibrancy effect for electron", "keywords": [ "node", diff --git a/src/win10refresh.ts b/src/win10refresh.ts index ff098c9..305a7e7 100644 --- a/src/win10refresh.ts +++ b/src/win10refresh.ts @@ -1,4 +1,3 @@ -import { VerticalRefreshRateContext } from '@seorii/win32-displayconfig' import { BrowserWindow } from './browserWindow' import * as electron from 'electron' import process from 'process' @@ -69,6 +68,8 @@ export default function win10refresh( win: BrowserWindow, maximumRefreshRate: number ) { + // Used require to only import dependency for windows only environments (supports compiling on mac without errors) + const { VerticalRefreshRateContext } = require('@seorii/win32-displayconfig') const refreshCtx = new VerticalRefreshRateContext() function getRefreshRateAtCursor( @@ -98,7 +99,7 @@ export default function win10refresh( desiredMoveBounds: electron.Rectangle | undefined let boundsPromise: any = Promise.race([ getRefreshRateAtCursor(electron.screen.getCursorScreenPoint()).then( - (rate) => { + (rate: number) => { pollingRate = rate || 30 doFollowUpQuery = true }