Browse Source

allow selecting windows vibrancy type (fixes #460)

Eugene Pankov 7 years ago
parent
commit
8f0f1b19df

+ 4 - 4
app/lib/window.ts

@@ -88,13 +88,13 @@ export class Window {
         })
     }
 
-    setVibrancy (enabled: boolean) {
+    setVibrancy (enabled: boolean, type?: string) {
         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) {
+                    if (parseInt(os.release().split('.')[2]) >= 17063 && type === 'fluent') {
                         attribValue = AccentState.ACCENT_ENABLE_FLUENT
                         color = 0x01000000 // using a small alpha because acrylic bugs out at full transparency.
                     } else {
@@ -186,8 +186,8 @@ export class Window {
             this.window.setAlwaysOnTop(flag)
         })
 
-        ipcMain.on('window-set-vibrancy', (_event, enabled) => {
-            this.setVibrancy(enabled)
+        ipcMain.on('window-set-vibrancy', (_event, enabled, type) => {
+            this.setVibrancy(enabled, type)
         })
 
         ipcMain.on('window-set-title', (_event, title) => {

+ 1 - 1
terminus-core/src/components/appRoot.component.ts

@@ -224,7 +224,7 @@ export class AppRootComponent {
     }
 
     private updateVibrancy () {
-        this.hostApp.setVibrancy(this.config.store.appearance.vibrancy)
+        this.hostApp.setVibrancy(this.config.store.appearance.vibrancy, this.config.store.appearance.vibrancyType)
         this.hostApp.getWindow().setOpacity(this.config.store.appearance.opacity)
     }
 }

+ 1 - 0
terminus-core/src/configDefaults.yaml

@@ -9,4 +9,5 @@ appearance:
   css: '/* * { color: blue !important; } */'
   opacity: 1.0
   vibrancy: false
+  vibrancyType: 'blur'
 enableAnalytics: true

+ 2 - 2
terminus-core/src/services/hostApp.service.ts

@@ -150,13 +150,13 @@ export class HostAppService {
         this.electron.ipcRenderer.send('window-set-always-on-top', flag)
     }
 
-    setVibrancy (enable: boolean) {
+    setVibrancy (enable: boolean, type: string) {
         document.body.classList.toggle('vibrant', enable)
         if (this.platform === Platform.macOS) {
             this.getWindow().setVibrancy(enable ? 'dark' : null)
         }
         if (this.platform === Platform.Windows) {
-            this.electron.ipcRenderer.send('window-set-vibrancy', enable)
+            this.electron.ipcRenderer.send('window-set-vibrancy', enable, type)
         }
     }
 

+ 23 - 0
terminus-settings/src/components/settingsTab.component.pug

@@ -69,6 +69,29 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
                     (ngModelChange)='config.save()'
                 )
 
+            .form-line(*ngIf='config.store.appearance.vibrancy && isFluentVibrancySupported')
+                .header
+                    .title Vibrancy type
+                .btn-group(
+                    [(ngModel)]='config.store.appearance.vibrancyType',
+                    (ngModelChange)='config.save()',
+                    ngbRadioGroup
+                )
+                    label.btn.btn-secondary(ngbButtonLabel)
+                        input(
+                            type='radio',
+                            ngbButton,
+                            [value]='"blur"'
+                        )
+                        | Blur
+                    label.btn.btn-secondary(ngbButtonLabel)
+                        input(
+                            type='radio',
+                            ngbButton,
+                            [value]='"fluent"'
+                        )
+                        | Fluent
+                    
             .form-line
                 .header
                     .title Window opacity

+ 6 - 0
terminus-settings/src/components/settingsTab.component.ts

@@ -1,4 +1,5 @@
 import * as yaml from 'js-yaml'
+import * as os from 'os'
 import { Subscription } from 'rxjs'
 import { Component, Inject, Input } from '@angular/core'
 import { HotkeysService } from 'terminus-core'
@@ -35,6 +36,7 @@ export class SettingsTabComponent extends BaseTabComponent {
     configDefaults: any
     configFile: string
     isShellIntegrationInstalled = false
+    isFluentVibrancySupported = false
     private configSubscription: Subscription
 
     constructor (
@@ -64,6 +66,10 @@ export class SettingsTabComponent extends BaseTabComponent {
         hotkeys.getHotkeyDescriptions().then(descriptions => {
             this.hotkeyDescriptions = descriptions
         })
+
+        this.isFluentVibrancySupported = process.platform === 'win32'
+            && parseFloat(os.release()) >= 10
+            && parseInt(os.release().split('.')[2]) >= 17063
     }
 
     async ngOnInit () {

+ 1 - 0
terminus-settings/webpack.config.js

@@ -46,6 +46,7 @@ module.exports = {
   externals: [
     'fs',
     'path',
+    'os',
     /^rxjs/,
     /^@angular/,
     /^@ng-bootstrap/,

+ 4 - 2
terminus-terminal/src/services/terminal.service.ts

@@ -29,12 +29,14 @@ export class TerminalService {
 
     async getShells (): Promise<IShell[]> {
         let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))
-        return shellLists.reduce((a, b) => a.concat(b))
+        return shellLists.reduce((a, b) => a.concat(b), [])
     }
 
     async reloadShells () {
         this.shells = new AsyncSubject<IShell[]>()
-        this.shells.next(await this.getShells())
+        let shells = await this.getShells()
+        this.logger.debug('Shells list:', shells)
+        this.shells.next(shells)
         this.shells.complete()
     }