mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-23 21:09:52 +00:00
reimplemented Windows vibrancy using windows-swca and windows-blurbehind (#383)
This commit is contained in:
parent
5b5d145bd0
commit
d104f5e771
@ -3,12 +3,21 @@ import { BrowserWindow, app, ipcMain, Rectangle } from 'electron'
|
|||||||
import ElectronConfig = require('electron-config')
|
import ElectronConfig = require('electron-config')
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
|
||||||
let electronVibrancy: any
|
let electronVibrancy: any
|
||||||
if (process.platform !== 'linux') {
|
let SetWindowCompositionAttribute: any
|
||||||
|
let AccentState: any
|
||||||
|
let DwmEnableBlurBehindWindow: any
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
electronVibrancy = require('electron-vibrancy')
|
electronVibrancy = require('electron-vibrancy')
|
||||||
}
|
}
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
SetWindowCompositionAttribute = require('windows-swca').SetWindowCompositionAttribute
|
||||||
|
AccentState = require('windows-swca').AccentState
|
||||||
|
DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow
|
||||||
|
}
|
||||||
|
|
||||||
export class Window {
|
export class Window {
|
||||||
ready: Promise<void>
|
ready: Promise<void>
|
||||||
@ -42,6 +51,7 @@ export class Window {
|
|||||||
webPreferences: { webSecurity: false },
|
webPreferences: { webSecurity: false },
|
||||||
frame: false,
|
frame: false,
|
||||||
show: false,
|
show: false,
|
||||||
|
backgroundColor: '#00000000'
|
||||||
}
|
}
|
||||||
Object.assign(options, this.windowBounds)
|
Object.assign(options, this.windowBounds)
|
||||||
|
|
||||||
@ -53,10 +63,6 @@ export class Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
|
||||||
options.transparent = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
options.backgroundColor = '#131d27'
|
options.backgroundColor = '#131d27'
|
||||||
}
|
}
|
||||||
@ -95,6 +101,23 @@ export class Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setVibrancy (enabled: boolean) {
|
setVibrancy (enabled: boolean) {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
if (parseFloat(os.release()) >= 10) {
|
||||||
|
let attribValue = AccentState.ACCENT_DISABLED
|
||||||
|
let color = 0x00000000
|
||||||
|
if (enabled) {
|
||||||
|
if (parseInt(os.release().split('.')[2]) >= 17063) {
|
||||||
|
attribValue = AccentState.ACCENT_ENABLE_FLUENT
|
||||||
|
color = 0x01000000 // using a small alpha because acrylic bugs out at full transparency.
|
||||||
|
} else {
|
||||||
|
attribValue = AccentState.ACCENT_ENABLE_BLURBEHIND
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetWindowCompositionAttribute(this.window, attribValue, color)
|
||||||
|
} else {
|
||||||
|
DwmEnableBlurBehindWindow(this.window, enabled)
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'darwin') {
|
||||||
if (enabled && !this.vibrancyViewID) {
|
if (enabled && !this.vibrancyViewID) {
|
||||||
this.vibrancyViewID = electronVibrancy.SetVibrancy(this.window, 0)
|
this.vibrancyViewID = electronVibrancy.SetVibrancy(this.window, 0)
|
||||||
} else if (!enabled && this.vibrancyViewID) {
|
} else if (!enabled && this.vibrancyViewID) {
|
||||||
@ -102,6 +125,7 @@ export class Window {
|
|||||||
this.vibrancyViewID = null
|
this.vibrancyViewID = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
show () {
|
show () {
|
||||||
this.window.show()
|
this.window.show()
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
"ngx-toastr": "^8.7.3",
|
"ngx-toastr": "^8.7.3",
|
||||||
"path": "0.12.7",
|
"path": "0.12.7",
|
||||||
"rxjs": "^6.1.0",
|
"rxjs": "^6.1.0",
|
||||||
|
"windows-blurbehind": "^1.0.0",
|
||||||
|
"windows-swca": "^1.1.1",
|
||||||
"yargs": "^12.0.1",
|
"yargs": "^12.0.1",
|
||||||
"zone.js": "~0.8.26"
|
"zone.js": "~0.8.26"
|
||||||
},
|
},
|
||||||
|
@ -41,6 +41,8 @@ module.exports = {
|
|||||||
mz: 'commonjs mz',
|
mz: 'commonjs mz',
|
||||||
path: 'commonjs path',
|
path: 'commonjs path',
|
||||||
yargs: 'commonjs yargs',
|
yargs: 'commonjs yargs',
|
||||||
|
'windows-swca': 'commonjs windows-swca',
|
||||||
|
'windows-blurbehind': 'commonjs windows-blurbehind',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||||
|
@ -532,6 +532,14 @@ which@^1.2.9:
|
|||||||
dependencies:
|
dependencies:
|
||||||
isexe "^2.0.0"
|
isexe "^2.0.0"
|
||||||
|
|
||||||
|
windows-blurbehind@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/windows-blurbehind/-/windows-blurbehind-1.0.0.tgz#050efb988704c44335bdc3efefd757f6e463b8ac"
|
||||||
|
|
||||||
|
windows-swca@^1.1.1:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/windows-swca/-/windows-swca-1.1.1.tgz#0b3530278c67d408baac71c3a6aeb16d55318bf8"
|
||||||
|
|
||||||
wrap-ansi@^2.0.0:
|
wrap-ansi@^2.0.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user