Skip to content

Commit 7e3fe7e

Browse files
committed
wip
1 parent 9b86ec0 commit 7e3fe7e

File tree

10 files changed

+25
-121
lines changed

10 files changed

+25
-121
lines changed

app/lib/window.ts

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import * as glasstron from 'glasstron'
21
import { autoUpdater } from 'electron-updater'
32
import { Subject, Observable, debounceTime } from 'rxjs'
43
import { BrowserWindow, app, ipcMain, Rectangle, Menu, screen, BrowserWindowConstructorOptions, TouchBar, nativeImage, WebContents } from 'electron'
54
import ElectronConfig = require('electron-config')
65
import { enable as enableRemote } from '@electron/remote/main'
7-
import * as os from 'os'
86
import * as path from 'path'
97
import macOSRelease from 'macos-release'
108
import { compare as compareVersions } from 'compare-versions'
@@ -16,11 +14,6 @@ export interface WindowOptions {
1614
hidden?: boolean
1715
}
1816

19-
abstract class GlasstronWindow extends BrowserWindow {
20-
blurType: string
21-
abstract setBlur (_: boolean)
22-
}
23-
2417
const macOSVibrancyType: any = process.platform === 'darwin' ? compareVersions(macOSRelease().version || '0.0', '10.14', '>=') ? 'under-window' : 'dark' : null
2518

2619
const activityIcon = nativeImage.createFromPath(`${app.getAppPath()}/assets/activity.png`)
@@ -31,14 +24,11 @@ export class Window {
3124
webContents: WebContents
3225
private visible = new Subject<boolean>()
3326
private closed = new Subject<void>()
34-
private window?: GlasstronWindow
27+
private window?: BrowserWindow
3528
private windowConfig: ElectronConfig
3629
private windowBounds?: Rectangle
3730
private closing = false
38-
private lastVibrancy: { enabled: boolean, type?: string } | null = null
39-
private disableVibrancyWhileDragging = false
4031
private touchBarControl: any
41-
private isFluentVibrancy = false
4232
private dockHidden = false
4333

4434
get visible$ (): Observable<boolean> { return this.visible }
@@ -66,6 +56,7 @@ export class Window {
6656
},
6757
maximizable: true,
6858
frame: false,
59+
transparent: true,
6960
show: false,
7061
backgroundColor: '#00000000',
7162
acceptFirstMouse: true,
@@ -95,11 +86,15 @@ export class Window {
9586
}
9687
}
9788

98-
if (process.platform === 'darwin') {
99-
this.window = new BrowserWindow(bwOptions) as GlasstronWindow
100-
} else {
101-
this.window = new glasstron.BrowserWindow(bwOptions)
102-
}
89+
this.window = new BrowserWindow(bwOptions)
90+
91+
// https://github.com/electron/electron/issues/39959#issuecomment-1758736966
92+
this.window.on('blur', () => {
93+
this.window.setBackgroundColor('#00000000')
94+
})
95+
this.window.on('focus', () => {
96+
this.window.setBackgroundColor('#00000000')
97+
})
10398

10499
this.webContents = this.window.webContents
105100

@@ -172,28 +167,12 @@ export class Window {
172167
this.window.webContents.send('host:became-main-window')
173168
}
174169

175-
setMaterial (material: string): void {
170+
setMaterial (material: 'mica'|'acrylic'|'auto'): void {
176171
this.window.setBackgroundMaterial(material)
177172
}
178173

179-
setVibrancy (enabled: boolean, type?: string, userRequested?: boolean): void {
180-
if (userRequested ?? true) {
181-
this.lastVibrancy = { enabled, type }
182-
}
183-
if (process.platform === 'win32') {
184-
if (parseFloat(os.release()) >= 10) {
185-
this.window.blurType = enabled ? type === 'fluent' ? 'acrylic' : 'blurbehind' : null
186-
try {
187-
this.window.setBlur(enabled)
188-
this.isFluentVibrancy = enabled && type === 'fluent'
189-
} catch (error) {
190-
console.error('Failed to set window blur', error)
191-
}
192-
}
193-
} else if (process.platform === 'linux') {
194-
this.window.setBackgroundColor(enabled ? '#00000000' : '#131d27')
195-
this.window.setBlur(enabled)
196-
} else {
174+
setVibrancy (enabled: boolean): void {
175+
if (process.platform === 'darwin') {
197176
this.window.setVibrancy(enabled ? macOSVibrancyType : null)
198177
}
199178
}
@@ -366,8 +345,8 @@ export class Window {
366345
this.window?.setAlwaysOnTop(flag)
367346
})
368347

369-
this.on('window-set-vibrancy', (_, enabled, type) => {
370-
this.setVibrancy(enabled, type)
348+
this.on('window-set-vibrancy', (_, enabled) => {
349+
this.setVibrancy(enabled)
371350
})
372351

373352
this.on('window-set-material', (_, material) => {
@@ -414,26 +393,6 @@ export class Window {
414393
return { action: 'deny' }
415394
})
416395

417-
ipcMain.on('window-set-disable-vibrancy-while-dragging', (_event, value) => {
418-
this.disableVibrancyWhileDragging = value && this.configStore.hacks?.disableVibrancyWhileDragging
419-
})
420-
421-
let moveEndedTimeout: any = null
422-
const onBoundsChange = () => {
423-
if (!this.lastVibrancy?.enabled || !this.disableVibrancyWhileDragging || !this.isFluentVibrancy) {
424-
return
425-
}
426-
this.setVibrancy(false, undefined, false)
427-
if (moveEndedTimeout) {
428-
clearTimeout(moveEndedTimeout)
429-
}
430-
moveEndedTimeout = setTimeout(() => {
431-
this.setVibrancy(this.lastVibrancy.enabled, this.lastVibrancy.type)
432-
}, 50)
433-
}
434-
this.window.on('move', onBoundsChange)
435-
this.window.on('resize', onBoundsChange)
436-
437396
ipcMain.on('window-set-traffic-light-position', (_event, x, y) => {
438397
this.window.setWindowButtonPosition({ x, y })
439398
})

app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"electron-promise-ipc": "^2.2.4",
2424
"electron-updater": "^5.2.1",
2525
"fontmanager-redux": "1.1.0",
26-
"glasstron": "0.1.1",
2726
"js-yaml": "4.1.0",
2827
"keytar": "^7.9.0",
2928
"mz": "^2.7.0",

app/webpack.config.main.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const config = {
4444
'electron-promise-ipc': 'commonjs electron-promise-ipc',
4545
'electron-updater': 'commonjs electron-updater',
4646
fs: 'commonjs fs',
47-
glasstron: 'commonjs glasstron',
4847
mz: 'commonjs mz',
4948
npm: 'commonjs npm',
5049
'node:os': 'commonjs os',

app/yarn.lock

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,6 @@
173173
dependencies:
174174
debug "^4.3.2"
175175

176-
"@tabby-gang/windows-blurbehind@^3.0.0":
177-
version "3.0.0"
178-
resolved "https://registry.yarnpkg.com/@tabby-gang/windows-blurbehind/-/windows-blurbehind-3.0.0.tgz#48d409c2eb14a12c867b70de5ee4d6769ef45e8f"
179-
integrity sha512-ah6eJcoQZWOZfu9sd2pWlOJmfl1v+2EZQMeIp7MWvg+/16WS16UFNdnOtlV6AUiABHfZo2QKfCNUEuorCM+Q2A==
180-
dependencies:
181-
"@types/node" "^10.12.18"
182-
183176
184177
version "2.7.4"
185178
resolved "https://registry.yarnpkg.com/@types/mz/-/mz-2.7.4.tgz#f9d1535cb5171199b28ae6abd6ec29e856551401"
@@ -192,11 +185,6 @@
192185
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.1.tgz#e8a83f1aa8b649377bb1fb5d7bac5cb90e784dfe"
193186
integrity sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==
194187

195-
"@types/node@^10.12.18":
196-
version "10.17.60"
197-
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"
198-
integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==
199-
200188
"@types/semver@^7.3.6":
201189
version "7.3.9"
202190
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.9.tgz#152c6c20a7688c30b967ec1841d31ace569863fc"
@@ -1481,14 +1469,6 @@ [email protected]:
14811469
resolved "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz"
14821470
integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=
14831471

1484-
1485-
version "0.1.1"
1486-
resolved "https://registry.yarnpkg.com/glasstron/-/glasstron-0.1.1.tgz#491a2e6f7e7b285c3776c5f7af7aaba2269833b2"
1487-
integrity sha512-oLEMQM5wwdAQ44NrXD3wjk+b3dsfQG1XtkLn5pCxQNa3ri1AtWvvzpnhFUd88ZTmguHvkY4c3JKzcPSYaJAKKA==
1488-
dependencies:
1489-
node-addon-api "^4.0.0"
1490-
x11 "^2.3.0"
1491-
14921472
glob@^10.2.2, glob@^10.3.10:
14931473
version "10.3.10"
14941474
resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.10.tgz#0351ebb809fd187fe421ab96af83d3a70715df4b"

tabby-core/src/configDefaults.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,5 @@ providerBlacklist: []
5454
profileBlacklist: []
5555
hacks:
5656
disableGPU: false
57-
disableVibrancyWhileDragging: false
58-
enableFluentBackground: false
5957
language: null
6058
defaultQuickConnectProvider: "ssh"

tabby-core/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
55
export const WIN_BUILD_CONPTY_SUPPORTED = 17692
66
export const WIN_BUILD_CONPTY_STABLE = 18309
77
export const WIN_BUILD_WSL_EXE_DISTRO_FLAG = 17763
8-
export const WIN_BUILD_FLUENT_BG_SUPPORTED = 17063
98
export const WIN_BUILD_WINDOW_MATERIAL_SUPPORTED = 22621
109

1110
export function getWindows10Build (): number|undefined {

tabby-electron/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule } from '@angular/core'
2-
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider, WIN_BUILD_WINDOW_MATERIAL_SUPPORTED } from 'tabby-core'
2+
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider, WIN_BUILD_WINDOW_MATERIAL_SUPPORTED } from 'tabby-core'
33
import { TerminalColorSchemeProvider } from 'tabby-terminal'
44
import { SFTPContextMenuItemProvider, SSHProfileImporter, AutoPrivateKeyLocator } from 'tabby-ssh'
55
import { PTYInterface, ShellProvider, UACService } from 'tabby-local'
@@ -178,11 +178,9 @@ export default class ElectronModule {
178178
return
179179
}
180180

181-
let vibrancyType = this.config.store.appearance.vibrancyType
182-
if (this.hostApp.platform === Platform.Windows && !isWindowsBuild(WIN_BUILD_FLUENT_BG_SUPPORTED)) {
183-
vibrancyType = null
181+
if (this.hostApp.platform === Platform.macOS) {
182+
this.electron.ipcRenderer.send('window-set-vibrancy', this.config.store.appearance.vibrancy)
184183
}
185-
this.electron.ipcRenderer.send('window-set-vibrancy', this.config.store.appearance.vibrancy, vibrancyType)
186184
}
187185

188186
private updateWindowControlsColor () {

tabby-electron/src/services/hostApp.service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable, NgZone, Injector } from '@angular/core'
2-
import { isWindowsBuild, WIN_BUILD_FLUENT_BG_SUPPORTED, HostAppService, Platform, CLIHandler, WIN_BUILD_WINDOW_MATERIAL_SUPPORTED } from 'tabby-core'
2+
import { HostAppService, Platform, CLIHandler } from 'tabby-core'
33
import { ElectronService } from '../services/electron.service'
44

55

@@ -48,10 +48,6 @@ export class ElectronHostAppService extends HostAppService {
4848
electron.ipcRenderer.on('host:config-change', () => this.zone.run(() => {
4949
this.configChangeBroadcast.next()
5050
}))
51-
52-
if (isWindowsBuild(WIN_BUILD_FLUENT_BG_SUPPORTED) && !isWindowsBuild(WIN_BUILD_WINDOW_MATERIAL_SUPPORTED)) {
53-
electron.ipcRenderer.send('window-set-disable-vibrancy-while-dragging', true)
54-
}
5551
}
5652

5753
newWindow (): void {

tabby-settings/src/components/windowSettingsTab.component.pug

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ h3.mb-3(translate) Window
3232
)
3333

3434

35-
.form-line(*ngIf='platform.supportsWindowControls')
35+
.form-line(*ngIf='platform.supportsWindowControls && (hostApp.platform !== Platform.Windows || isWindowMaterialSupported)')
3636
.header
3737
.title(*ngIf='hostApp.platform !== Platform.macOS', translate) Blurred background
3838
.title(*ngIf='hostApp.platform === Platform.macOS', translate) Vibrancy
39-
.description(*ngIf='hostApp.platform !== Platform.Linux', translate) Gives the window a blurred transparent background
40-
.description(*ngIf='hostApp.platform === Platform.Linux', translate) Enables transparent windows background under KWM
39+
.description(*ngIf='hostApp.platform === Platform.Linux', translate) Gives the window a blurred transparent background
4140

4241
toggle(
4342
[(ngModel)]='config.store.appearance.vibrancy',
4443
(ngModelChange)='saveConfiguration()'
4544
)
4645

47-
.form-line(*ngIf='config.store.appearance.vibrancy && (isWindowMaterialSupported || (isFluentVibrancySupported && config.store.hacks.enableFluentBackground))')
46+
.form-line(*ngIf='config.store.appearance.vibrancy && isWindowMaterialSupported')
4847
.header
4948
.title(translate) Background type
5049
.btn-group
@@ -59,7 +58,7 @@ h3.mb-3(translate) Window
5958
label.btn.btn-secondary(
6059
for='vibrancyTypeBlur'
6160
)
62-
span(translate) Blur
61+
span(translate) Acrylic
6362
input.btn-check(
6463
type='radio',
6564
name='vibracy',
@@ -71,7 +70,7 @@ h3.mb-3(translate) Window
7170
label.btn.btn-secondary(
7271
for='vibrancyTypeFluent'
7372
)
74-
span Fluent
73+
span Mica
7574

7675
.form-line(*ngIf='platform.supportsWindowControls')
7776
.header
@@ -423,23 +422,3 @@ h3.mt-4(translate) Hacks
423422
[(ngModel)]='config.store.hacks.disableGPU',
424423
(ngModelChange)='config.save(); config.requestRestart()'
425424
)
426-
427-
.form-line(*ngIf='hostApp.platform === Platform.Windows && isFluentVibrancySupported')
428-
.header
429-
.title(translate) Enable fluent background option
430-
.description(translate) Experimental Windows 10 background style known to cause issues
431-
432-
toggle(
433-
[(ngModel)]='config.store.hacks.enableFluentBackground',
434-
(ngModelChange)='config.save()'
435-
)
436-
437-
.form-line(*ngIf='hostApp.platform === Platform.Windows && isFluentVibrancySupported')
438-
.header
439-
.title(translate) Disable fluent background while dragging
440-
.description(translate) Fluent background sometimes causes drag lag
441-
442-
toggle(
443-
[(ngModel)]='config.store.hacks.disableVibrancyWhileDragging',
444-
(ngModelChange)='config.save(); config.requestRestart()'
445-
)

tabby-settings/src/components/windowSettingsTab.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
HostAppService,
99
Platform,
1010
isWindowsBuild,
11-
WIN_BUILD_FLUENT_BG_SUPPORTED,
1211
BaseComponent,
1312
Screen,
1413
PlatformService,
@@ -24,7 +23,6 @@ import {
2423
export class WindowSettingsTabComponent extends BaseComponent {
2524
screens: Screen[]
2625
Platform = Platform
27-
isFluentVibrancySupported = false
2826
isWindowMaterialSupported = false
2927

3028
@HostBinding('class.content-box') true
@@ -49,7 +47,6 @@ export class WindowSettingsTabComponent extends BaseComponent {
4947
this.screens = dockingService.getScreens()
5048
}
5149

52-
this.isFluentVibrancySupported = isWindowsBuild(WIN_BUILD_FLUENT_BG_SUPPORTED)
5350
this.isWindowMaterialSupported = isWindowsBuild(WIN_BUILD_WINDOW_MATERIAL_SUPPORTED)
5451
}
5552

0 commit comments

Comments
 (0)