From 8f0f1b19dfb226f8d139fd6ea54c199f2528fe5b Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 13 Oct 2018 04:30:12 -0700 Subject: [PATCH] allow selecting windows vibrancy type (fixes #460) --- app/lib/window.ts | 8 +++---- .../src/components/appRoot.component.ts | 2 +- terminus-core/src/configDefaults.yaml | 1 + terminus-core/src/services/hostApp.service.ts | 4 ++-- .../src/components/settingsTab.component.pug | 23 +++++++++++++++++++ .../src/components/settingsTab.component.ts | 6 +++++ terminus-settings/webpack.config.js | 1 + .../src/services/terminal.service.ts | 6 +++-- 8 files changed, 42 insertions(+), 9 deletions(-) diff --git a/app/lib/window.ts b/app/lib/window.ts index d34bb1d8..4bce2adf 100644 --- a/app/lib/window.ts +++ b/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) => { diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index 93f63881..777817bd 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/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) } } diff --git a/terminus-core/src/configDefaults.yaml b/terminus-core/src/configDefaults.yaml index 13ffa5f2..01251dd6 100644 --- a/terminus-core/src/configDefaults.yaml +++ b/terminus-core/src/configDefaults.yaml @@ -9,4 +9,5 @@ appearance: css: '/* * { color: blue !important; } */' opacity: 1.0 vibrancy: false + vibrancyType: 'blur' enableAnalytics: true diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index a64d2d78..9d89bda5 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/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) } } diff --git a/terminus-settings/src/components/settingsTab.component.pug b/terminus-settings/src/components/settingsTab.component.pug index 6ddcd660..905a90da 100644 --- a/terminus-settings/src/components/settingsTab.component.pug +++ b/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 diff --git a/terminus-settings/src/components/settingsTab.component.ts b/terminus-settings/src/components/settingsTab.component.ts index 238cbe95..cd2bf3bf 100644 --- a/terminus-settings/src/components/settingsTab.component.ts +++ b/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 () { diff --git a/terminus-settings/webpack.config.js b/terminus-settings/webpack.config.js index c7e8c2bd..64f612fa 100644 --- a/terminus-settings/webpack.config.js +++ b/terminus-settings/webpack.config.js @@ -46,6 +46,7 @@ module.exports = { externals: [ 'fs', 'path', + 'os', /^rxjs/, /^@angular/, /^@ng-bootstrap/, diff --git a/terminus-terminal/src/services/terminal.service.ts b/terminus-terminal/src/services/terminal.service.ts index 56e8b650..325a4f76 100644 --- a/terminus-terminal/src/services/terminal.service.ts +++ b/terminus-terminal/src/services/terminal.service.ts @@ -29,12 +29,14 @@ export class TerminalService { async getShells (): Promise { 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() - this.shells.next(await this.getShells()) + let shells = await this.getShells() + this.logger.debug('Shells list:', shells) + this.shells.next(shells) this.shells.complete() }