mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
updated window docking logic
This commit is contained in:
@@ -23,6 +23,7 @@ export class Application {
|
||||
private windows: Window[] = []
|
||||
private globalHotkey$ = new Subject<void>()
|
||||
private quitRequested = false
|
||||
private configStore: any
|
||||
userPluginsPath: string
|
||||
|
||||
constructor () {
|
||||
@@ -32,6 +33,7 @@ export class Application {
|
||||
|
||||
ipcMain.on('app:config-change', (_event, config) => {
|
||||
this.broadcast('host:config-change', config)
|
||||
this.configStore = config
|
||||
})
|
||||
|
||||
ipcMain.on('app:register-global-hotkey', (_event, specs) => {
|
||||
@@ -61,10 +63,10 @@ export class Application {
|
||||
}
|
||||
})
|
||||
|
||||
const configData = loadConfig()
|
||||
this.configStore = loadConfig()
|
||||
if (process.platform === 'linux') {
|
||||
app.commandLine.appendSwitch('no-sandbox')
|
||||
if (((configData.appearance || {}).opacity || 1) !== 1) {
|
||||
if (((this.configStore.appearance || {}).opacity || 1) !== 1) {
|
||||
app.commandLine.appendSwitch('enable-transparent-visuals')
|
||||
app.disableHardwareAcceleration()
|
||||
}
|
||||
@@ -84,7 +86,7 @@ export class Application {
|
||||
app.commandLine.appendSwitch('lang', 'EN')
|
||||
app.allowRendererProcessReuse = false
|
||||
|
||||
for (const flag of configData.flags || [['force_discrete_gpu', '0']]) {
|
||||
for (const flag of this.configStore.flags || [['force_discrete_gpu', '0']]) {
|
||||
app.commandLine.appendSwitch(flag[0], flag[1])
|
||||
}
|
||||
|
||||
@@ -104,6 +106,9 @@ export class Application {
|
||||
async newWindow (options?: WindowOptions): Promise<Window> {
|
||||
const window = new Window(this, options)
|
||||
this.windows.push(window)
|
||||
if (this.windows.length === 1){
|
||||
window.makeMain()
|
||||
}
|
||||
window.visible$.subscribe(visible => {
|
||||
if (visible) {
|
||||
this.disableTray()
|
||||
@@ -113,16 +118,28 @@ export class Application {
|
||||
})
|
||||
window.closed$.subscribe(() => {
|
||||
this.windows = this.windows.filter(x => x !== window)
|
||||
if (!this.windows.some(x => x.isMainWindow)) {
|
||||
this.windows[0]?.makeMain()
|
||||
this.windows[0]?.present()
|
||||
}
|
||||
})
|
||||
if (process.platform === 'darwin') {
|
||||
this.setupMenu()
|
||||
}
|
||||
await window.ready
|
||||
window.present()
|
||||
return window
|
||||
}
|
||||
|
||||
onGlobalHotkey (): void {
|
||||
if (this.windows.some(x => x.isFocused() && x.isVisible())) {
|
||||
let isPresent = this.windows.some(x => x.isFocused() && x.isVisible())
|
||||
const isDockedOnTop = this.windows.some(x => x.isDockedOnTop())
|
||||
if (isDockedOnTop) {
|
||||
// if docked and on top, hide even if not focused right now
|
||||
isPresent = this.windows.some(x => x.isVisible())
|
||||
}
|
||||
|
||||
if (isPresent) {
|
||||
for (const window of this.windows) {
|
||||
window.hide()
|
||||
}
|
||||
@@ -191,7 +208,7 @@ export class Application {
|
||||
|
||||
focus (): void {
|
||||
for (const window of this.windows) {
|
||||
window.show()
|
||||
window.present()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user