Properly identify primary display and ensure all screens are sorted by their X/Y bounds

This commit is contained in:
Austin Warren 2019-06-28 13:26:17 -07:00
parent fa6fa3f1ea
commit 38494c9704

View File

@ -63,15 +63,15 @@ export class DockingService {
} }
getScreens () { getScreens () {
return this.electron.screen.getAllDisplays().map((display, index) => { const primaryDisplayID = this.electron.screen.getPrimaryDisplay().id;
return this.electron.screen.getAllDisplays().sort((a,b) => (
a.bounds.x === b.bounds.x ? a.bounds.y - b.bounds.y : a.bounds.x - b.bounds.x
)).map((display,index) => {
return { return {
id: display.id, id: display.id,
name: [ name: display.id === primaryDisplayID ? 'Primary Display' : `Display ${index +1}`,
'Primary display',
'Secondary display',
][index] || `Display ${index + 1}`,
} }
}) });
} }
private repositionWindow () { private repositionWindow () {