1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-24 06:04:04 +03:00

faster tab switching

This commit is contained in:
Eugene Pankov 2018-09-20 11:42:51 +02:00
parent c8b40647a9
commit cec349d021
5 changed files with 19 additions and 6 deletions

View File

@ -182,6 +182,10 @@ export class Window {
ipcMain.on('window-set-vibrancy', (_event, enabled) => { ipcMain.on('window-set-vibrancy', (_event, enabled) => {
this.setVibrancy(enabled) this.setVibrancy(enabled)
}) })
ipcMain.on('window-set-title', (_event, title) => {
this.window.setTitle(title)
})
} }
private destroy () { private destroy () {

View File

@ -13,8 +13,6 @@ $tabs-height: 36px;
overflow: hidden; overflow: hidden;
transition: 0.125s ease-out all;
.index { .index {
flex: none; flex: none;
font-weight: bold; font-weight: bold;

View File

@ -50,7 +50,7 @@ export class AppService {
tab.titleChange$.subscribe(title => { tab.titleChange$.subscribe(title => {
if (tab === this.activeTab) { if (tab === this.activeTab) {
this.hostApp.getWindow().setTitle(title) this.hostApp.setTitle(title)
} }
}) })
return tab return tab
@ -75,7 +75,7 @@ export class AppService {
if (this.activeTab) { if (this.activeTab) {
this.activeTab.emitFocused() this.activeTab.emitFocused()
} }
this.hostApp.getWindow().setTitle(this.activeTab.title) this.hostApp.setTitle(this.activeTab.title)
} }
toggleLastTab () { toggleLastTab () {

View File

@ -151,6 +151,10 @@ export class HostAppService {
} }
} }
setTitle (title: string) {
this.electron.ipcRenderer.send('window-set-title', title)
}
broadcastConfigChange () { broadcastConfigChange () {
this.electron.ipcRenderer.send('app:config-change') this.electron.ipcRenderer.send('app:config-change')
} }

View File

@ -10,6 +10,7 @@ import { IToolbarButton, ToolbarButtonProvider } from '../api'
export class TouchbarService { export class TouchbarService {
private tabsSegmentedControl: TouchBarSegmentedControl private tabsSegmentedControl: TouchBarSegmentedControl
private tabSegments: SegmentedControlSegment[] = [] private tabSegments: SegmentedControlSegment[] = []
private nsImageCache: {[id: string]: Electron.NativeImage} = {}
constructor ( constructor (
private app: AppService, private app: AppService,
@ -59,12 +60,18 @@ export class TouchbarService {
private getButton (button: IToolbarButton): Electron.TouchBarButton { private getButton (button: IToolbarButton): Electron.TouchBarButton {
return new this.electron.TouchBar.TouchBarButton({ return new this.electron.TouchBar.TouchBarButton({
label: button.touchBarNSImage ? null : this.shortenTitle(button.touchBarTitle || button.title), label: button.touchBarNSImage ? null : this.shortenTitle(button.touchBarTitle || button.title),
icon: button.touchBarNSImage ? icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : null,
this.electron.nativeImage.createFromNamedImage(button.touchBarNSImage, [0, 0, 1]) : null,
click: () => this.zone.run(() => button.click()), click: () => this.zone.run(() => button.click()),
}) })
} }
private getCachedNSImage (name: string) {
if (!this.nsImageCache[name]) {
this.nsImageCache[name] = this.electron.nativeImage.createFromNamedImage(name, [0, 0, 1])
}
return this.nsImageCache[name]
}
private shortenTitle (title: string): string { private shortenTitle (title: string): string {
if (title.length > 15) { if (title.length > 15) {
title = title.substring(0, 15) + '...' title = title.substring(0, 15) + '...'