Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Added Mac support to allow use in cross-platform environments #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

coolwr
Copy link

@coolwr coolwr commented Aug 16, 2022

Added mac support for cross-platform apps. Previous build was erroring on macs due to @seorii/win32-displayconfig dependency. The change makes the dependency only used if calling win10refresh(). Also, see updated README.md on how to use with Windows and Mac configurations.

… errors. See updated README.md on how to use with Windows and Mac conigurations.
Comment on lines +134 to +179
## 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);
});


```

Copy link
Collaborator

Choose a reason for hiding this comment

The 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:

"Only affects Windows 10. If the OS is not Windows 10, it will fall back on the original vibrancy function.".

Comment on lines +130 to +133
## Known Issues

* Known issue on Windows 11 - opening web developer tools will disable the acrylic effect.

Copy link
Collaborator

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.

@@ -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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { VerticalRefreshRateContext } = require('@seorii/win32-displayconfig')
const { VerticalRefreshRateContext } = require('@seorii/win32-displayconfig') as typeof import('@seorii/win32-displayconfig')

@tscpp
Copy link
Collaborator

tscpp commented Aug 17, 2022

Thank you for you pull request!

I have some suggested changes. Also, please squash your commits for better history.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants