mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-23 16:46:03 +00:00
perf: avoid gpu memory increase
This commit is contained in:
@@ -75,6 +75,7 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||||||
private titleChange = new Subject<string>()
|
private titleChange = new Subject<string>()
|
||||||
private focused = new Subject<void>()
|
private focused = new Subject<void>()
|
||||||
private blurred = new Subject<void>()
|
private blurred = new Subject<void>()
|
||||||
|
private visibility = new Subject<boolean>()
|
||||||
private progress = new Subject<number|null>()
|
private progress = new Subject<number|null>()
|
||||||
private activity = new Subject<boolean>()
|
private activity = new Subject<boolean>()
|
||||||
private destroyed = new Subject<void>()
|
private destroyed = new Subject<void>()
|
||||||
@@ -83,6 +84,7 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||||||
|
|
||||||
get focused$ (): Observable<void> { return this.focused }
|
get focused$ (): Observable<void> { return this.focused }
|
||||||
get blurred$ (): Observable<void> { return this.blurred }
|
get blurred$ (): Observable<void> { return this.blurred }
|
||||||
|
get visibility$ (): Observable<boolean> { return this.visibility }
|
||||||
get titleChange$ (): Observable<string> { return this.titleChange.pipe(distinctUntilChanged()) }
|
get titleChange$ (): Observable<string> { return this.titleChange.pipe(distinctUntilChanged()) }
|
||||||
get progress$ (): Observable<number|null> { return this.progress.pipe(distinctUntilChanged()) }
|
get progress$ (): Observable<number|null> { return this.progress.pipe(distinctUntilChanged()) }
|
||||||
get activity$ (): Observable<boolean> { return this.activity }
|
get activity$ (): Observable<boolean> { return this.activity }
|
||||||
@@ -177,6 +179,10 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||||||
this.blurred.next()
|
this.blurred.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitVisibility (visibility: boolean): void {
|
||||||
|
this.visibility.next(visibility)
|
||||||
|
}
|
||||||
|
|
||||||
insertIntoContainer (container: ViewContainerRef): EmbeddedViewRef<any> {
|
insertIntoContainer (container: ViewContainerRef): EmbeddedViewRef<any> {
|
||||||
this.viewContainerEmbeddedRef = container.insert(this.hostView) as EmbeddedViewRef<any>
|
this.viewContainerEmbeddedRef = container.insert(this.hostView) as EmbeddedViewRef<any>
|
||||||
this.viewContainer = container
|
this.viewContainer = container
|
||||||
|
@@ -275,6 +275,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.blurred$.subscribe(() => this.getAllTabs().forEach(x => x.emitBlurred()))
|
this.blurred$.subscribe(() => this.getAllTabs().forEach(x => x.emitBlurred()))
|
||||||
|
this.visibility$.subscribe(visibility => this.getAllTabs().forEach(x => x.emitVisibility(visibility)))
|
||||||
|
|
||||||
this.tabAdded$.subscribe(() => this.updateTitle())
|
this.tabAdded$.subscribe(() => this.updateTitle())
|
||||||
this.tabRemoved$.subscribe(() => this.updateTitle())
|
this.tabRemoved$.subscribe(() => this.updateTitle())
|
||||||
|
@@ -230,11 +230,13 @@ export class AppService {
|
|||||||
if (this._activeTab) {
|
if (this._activeTab) {
|
||||||
this._activeTab.clearActivity()
|
this._activeTab.clearActivity()
|
||||||
this._activeTab.emitBlurred()
|
this._activeTab.emitBlurred()
|
||||||
|
this._activeTab.emitVisibility(false)
|
||||||
}
|
}
|
||||||
this._activeTab = tab
|
this._activeTab = tab
|
||||||
this.activeTabChange.next(tab)
|
this.activeTabChange.next(tab)
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this._activeTab?.emitFocused()
|
this._activeTab?.emitFocused()
|
||||||
|
this._activeTab?.emitVisibility(true)
|
||||||
})
|
})
|
||||||
this.hostWindow.setTitle(this._activeTab?.title)
|
this.hostWindow.setTitle(this._activeTab?.title)
|
||||||
}
|
}
|
||||||
|
@@ -408,6 +408,23 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
|
|||||||
this.blurred$.subscribe(() => {
|
this.blurred$.subscribe(() => {
|
||||||
this.multifocus.cancel()
|
this.multifocus.cancel()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.visibility$.subscribe(visibility => {
|
||||||
|
if (this.frontend instanceof XTermFrontend) {
|
||||||
|
if (visibility) {
|
||||||
|
// this.frontend.resizeHandler()
|
||||||
|
const term = this.frontend.xterm as any
|
||||||
|
term._core._renderService.clear()
|
||||||
|
term._core._renderService.handleResize(term.cols, term.rows)
|
||||||
|
} else {
|
||||||
|
this.frontend.xterm.element?.querySelectorAll('canvas').forEach(c => {
|
||||||
|
c.height = c.width = 0
|
||||||
|
c.style.height = c.style.width = '0px'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('visibility:', this.title, visibility)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onFrontendReady (): void {
|
protected onFrontendReady (): void {
|
||||||
|
@@ -66,7 +66,7 @@ export class XTermFrontend extends Frontend {
|
|||||||
private configuredFontSize = 0
|
private configuredFontSize = 0
|
||||||
private configuredLinePadding = 0
|
private configuredLinePadding = 0
|
||||||
private zoom = 0
|
private zoom = 0
|
||||||
private resizeHandler: () => void
|
resizeHandler: () => void
|
||||||
private configuredTheme: ITheme = {}
|
private configuredTheme: ITheme = {}
|
||||||
private copyOnSelect = false
|
private copyOnSelect = false
|
||||||
private preventNextOnSelectionChangeEvent = false
|
private preventNextOnSelectionChangeEvent = false
|
||||||
|
Reference in New Issue
Block a user