less sync ipc

上级 18524868
......@@ -398,6 +398,18 @@ export class Window {
}
this.window.on('move', onBoundsChange)
this.window.on('resize', onBoundsChange)
ipcMain.on('window-set-traffic-light-position', (_event, x, y) => {
this.window.setTrafficLightPosition({ x, y })
})
ipcMain.on('window-set-opacity', (_event, opacity) => {
this.window.setOpacity(opacity)
})
ipcMain.on('window-set-progress-bar', (_event, value) => {
this.window.setProgressBar(value, { mode: value < 0 ? 'none' : 'normal' })
})
}
private destroy () {
......
......@@ -59,10 +59,10 @@ export default class ElectronModule {
themeService.themeChanged$.subscribe(theme => {
if (hostApp.platform === Platform.macOS) {
hostWindow.getWindow().setTrafficLightPosition({
x: theme.macOSWindowButtonsInsetX ?? 14,
y: theme.macOSWindowButtonsInsetY ?? 11,
})
hostWindow.setTrafficLightPosition(
theme.macOSWindowButtonsInsetX ?? 14,
theme.macOSWindowButtonsInsetY ?? 11,
)
}
})
......@@ -73,9 +73,9 @@ export default class ElectronModule {
return
}
if (progress !== null) {
hostWindow.getWindow().setProgressBar(progress / 100.0, { mode: 'normal' })
hostWindow.setProgressBar(progress / 100.0)
} else {
hostWindow.getWindow().setProgressBar(-1, { mode: 'none' })
hostWindow.setProgressBar(-1)
}
lastProgress = progress
})
......@@ -116,7 +116,7 @@ export default class ElectronModule {
document.body.classList.toggle('vibrant', this.config.store.appearance.vibrancy)
this.electron.ipcRenderer.send('window-set-vibrancy', this.config.store.appearance.vibrancy, vibrancyType)
this.hostWindow.getWindow().setOpacity(this.config.store.appearance.opacity)
this.hostWindow.setOpacity(this.config.store.appearance.opacity)
}
}
......
......@@ -97,6 +97,18 @@ export class ElectronHostWindow extends HostWindowService {
this.getWindow().setTouchBar(touchBar)
}
setTrafficLightPosition (x: number, y: number): void {
this.electron.ipcRenderer.send('window-set-traffic-light-position', x, y)
}
setOpacity (opacity: number): void {
this.electron.ipcRenderer.send('window-set-opacity', opacity)
}
setProgressBar (value: number): void {
this.electron.ipcRenderer.send('window-set-progress-bar', value)
}
bringToFront (): void {
this.electron.ipcRenderer.send('window-bring-to-front')
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册