This repository was archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Added Mac support to allow use in cross-platform environments #95
Open
coolwr
wants to merge
2
commits into
seo-rii:master
Choose a base branch
from
coolwr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| }); | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
|
Comment on lines
+134
to
+179
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not be necessary to make separate windows and configs depending on the os. The original and build-in vibrancy functionally of electron is used when the os is not windows. This is explicitly written in the beginning of the readme:
|
||
| ## Demo | ||
|
|
||
| To run the demo Electron application, clone this repository, install the dependencies and run the test script: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -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') | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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 | ||||||
| } | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this specific issue needs to documented in the readme. All the issues are already documented in https://github.com/Seo-Rii/electron-acrylic-window/issues.