mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-10 06:20:03 +00:00
auto reposition window on resolution changes (fixes #150)
This commit is contained in:
parent
1614405c62
commit
0fe7edc5b5
@ -14,7 +14,10 @@ export class DockingService {
|
||||
private electron: ElectronService,
|
||||
private config: ConfigService,
|
||||
private hostApp: HostAppService,
|
||||
) {}
|
||||
) {
|
||||
electron.screen.on('display-removed', () => this.repositionWindow())
|
||||
electron.screen.on('display-metrics-changed', () => this.repositionWindow())
|
||||
}
|
||||
|
||||
dock () {
|
||||
let display = this.electron.screen.getAllDisplays()
|
||||
@ -71,4 +74,20 @@ export class DockingService {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getWindow () {
|
||||
return this.electron.app.window
|
||||
}
|
||||
|
||||
repositionWindow () {
|
||||
let [x, y] = this.getWindow().getPosition()
|
||||
for (let screen of this.electron.screen.getAllDisplays()) {
|
||||
let bounds = screen.bounds
|
||||
if (x >= bounds.x && x <= bounds.x + bounds.width && y >= bounds.y && y <= bounds.y + bounds.height) {
|
||||
return
|
||||
}
|
||||
}
|
||||
let screen = this.electron.screen.getPrimaryDisplay()
|
||||
this.getWindow().setPosition(screen.bounds.x, screen.bounds.y)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user