positioner.js
function calculateXAlign (windowBounds, trayBounds, align) {
  const display = getDisplay()
  let x

  switch (align) {
    case 'right':
      x = trayBounds.x
      break
    case 'left':
      x = trayBounds.x + trayBounds.width - windowBounds.width
      break
    case 'center':
    default:
      x = Math.round(trayBounds.x + (trayBounds.width / 2) - (windowBounds.width / 2))
  }

  if (x + windowBounds.width > display.bounds.width && align !== 'left') {
    // if window would overlap on right side align it to the end of the screen
    x = display.bounds.width - windowBounds.width
  } else if (x < 0 && align !== 'right') {
    // if window would overlap on the left side align it to the beginning
    x = 0
  }

  return x
}
function calculateXAlign (windowBounds, trayBounds, align) {
  const display = getDisplay()
  let x

  switch (align) {
    case 'right':
      x = trayBounds.x
      break
    case 'left':
      x = trayBounds.x + trayBounds.width - windowBounds.width
      break
    case 'center':
    default:
      x = Math.round(trayBounds.x + (trayBounds.width / 2) - (windowBounds.width / 2))
  }

  if (x + windowBounds.width > display.bounds.width && align !== 'left') {
    // if window would overlap on right side align it to the end of the screen
    x = display.bounds.width - windowBounds.width
  } else if (x < 0 && align !== 'right') {
    // if window would overlap on the left side align it to the beginning
    x = 0
  }

  return x
}
function calculateXAlign ( windowBounds , trayBounds , align ) { const display = getDisplay ( ) let x switch ( align ) { case 'right' : x = trayBounds . x break case 'left' : x = trayBounds . x + trayBounds . width - windowBounds . width break case 'center' : default : x = Math . round ( trayBounds . x + ( trayBounds . width / 2 ) - ( windowBounds . width / 2 ) ) } if ( x + windowBounds . width > display . bounds . width && align !== 'left' ) { // if window would overlap on right side align it to the end of the screen x = display . bounds . width - windowBounds . width } else if ( x < 0 && align !== 'right' ) { // if window would overlap on the left side align it to the beginning x = 0 } return x }
Calculates the x position of the tray window

@param {Rectangle} windowBounds - electron BrowserWindow bounds of tray window to position
@param {Rectangle} trayBounds - tray bounds from electron Tray.getBounds()
@param {string} [align] - align left|center|right, default: center

@return {integer} - calculated x position
Calculates the x position of the tray window