diff --git a/app/lib/window.ts b/app/lib/window.ts index c2d5c94c..e3a8e4c3 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -1,5 +1,5 @@ import * as glasstron from 'glasstron' -if (process.platform === 'linux') { +if (process.platform === 'win32' || process.platform === 'linux') { glasstron.init() } @@ -13,12 +13,8 @@ import * as path from 'path' import { parseArgs } from './cli' import { loadConfig } from './config' -let SetWindowCompositionAttribute: any -let AccentState: any let DwmEnableBlurBehindWindow: any if (process.platform === 'win32') { - SetWindowCompositionAttribute = require('windows-swca').SetWindowCompositionAttribute - AccentState = require('windows-swca').ACCENT_STATE DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow } @@ -89,12 +85,6 @@ export class Window { this.window = new BrowserWindow(bwOptions) - if (process.platform === 'linux') { - glasstron.update(this.window, { - linux: { requestBlur: true }, - }) - } - this.window.once('ready-to-show', () => { if (process.platform === 'darwin') { this.window.setVibrancy('window') @@ -142,19 +132,16 @@ export class Window { this.lastVibrancy = { enabled, type } if (process.platform === 'win32') { if (parseFloat(os.release()) >= 10) { - let attribValue = AccentState.ACCENT_DISABLED - if (enabled) { - if (type === 'fluent') { - attribValue = AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND - } else { - attribValue = AccentState.ACCENT_ENABLE_BLURBEHIND - } - } - SetWindowCompositionAttribute(this.window.getNativeWindowHandle(), attribValue, 0x00000000) + glasstron.update(this.window, { + windows: { blurType: enabled ? ((type === 'fluent') ? 'acrylic' : 'blurbehind') : null }, + }) } else { DwmEnableBlurBehindWindow(this.window, enabled) } - }else if(process.platform ==='linux'){ + } else if (process.platform ==='linux') { + glasstron.update(this.window, { + linux: { requestBlur: enabled }, + }) this.window.setBackgroundColor(enabled ? '#00000000' : '#131d27') } else { this.window.setVibrancy(enabled ? 'dark' : null as any) // electron issue 20269 diff --git a/app/package.json b/app/package.json index 9afbc3c0..e5acc635 100644 --- a/app/package.json +++ b/app/package.json @@ -27,7 +27,7 @@ "electron-is-dev": "1.1.0", "electron-updater": "^4.3.1", "fontmanager-redux": "0.4.0", - "glasstron": "0.0.3", + "glasstron": "sentialx/Glasstron#n-api", "js-yaml": "3.14.0", "keytar": "^6.0.1", "mz": "^2.7.0", @@ -45,8 +45,7 @@ "serialport": "^9.0.0", "windows-blurbehind": "^1.0.1", "windows-native-registry": "^1.0.17", - "windows-process-tree": "^0.2.4", - "windows-swca": "^2.0.2" + "windows-process-tree": "^0.2.4" }, "devDependencies": { "@types/mz": "0.0.32", diff --git a/app/yarn.lock b/app/yarn.lock index eecca084..c30fd6f1 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -1186,11 +1186,11 @@ github-from-package@0.0.0: resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= -glasstron@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/glasstron/-/glasstron-0.0.3.tgz#3934d9e9b51dd2fd6b07eff8395493b3361ab917" - integrity sha512-yJ8+8gkGXXBlnI+4j6i8N+SaeZcswtrO82M863zQkCc5BQfC5fTXcwj9+v80f0jYUfZLFigsgaFuKoFmlVsOdw== +glasstron@sentialx/Glasstron#n-api: + version "0.0.4" + resolved "https://codeload.github.com/sentialx/Glasstron/tar.gz/1159908e1d85b8cceabf6b5d9353c446caea1f0b" dependencies: + node-addon-api "^3.0.0" x11 "^2.3.0" glob@^7.0.3, glob@^7.1.1, glob@^7.1.3: