mawie81 / electron-window-state

A library to store and restore window sizes and positions for your Electron app
MIT License
655 stars 67 forks source link

Multiple monitors, window opens on wrong monitor #27

Open adamdry opened 6 years ago

adamdry commented 6 years ago

I did these steps:

I'm running Ubuntu 16.04, using node 7.9.0, Chrome 58.0.3029.110, and Electron 1.7.8

Edit: Further testing shows that my app's window will maximise on which ever screen the terminal window I'm launching it from is on

tobiasmuecksch commented 5 years ago

@adamdry This issue should have been fixed in the latest version 5.0.3

Please check and close this issue if solved.

ThexXTURBOXx commented 5 years ago

I am using altus, which uses 5.0.3. The issue still seems to exist for me: https://github.com/ShadyThGod/altus/issues/20. I also reported an issue here as well with a workaround for users: https://github.com/electron/electron/issues/17933 Maybe this could help resolving the issue?

danivalls commented 4 years ago

It keeps happening to me too. This is the configuration I have:

import { app, BrowserWindow } from 'electron'
import windowStateKeeper from 'electron-window-state'

let mainWindow

function createWindow () {
  /**
   * Load the previous state with fallback to defaults
   */
  let mainWindowState = windowStateKeeper({
    defaultWidth: 1000,
    defaultHeight: 600
  })

  /**
   * Initial window options
   */
  const { width, height, x, y } = mainWindowState

  mainWindow = new BrowserWindow({
    width,
    height,
    x,
    y,
    webPreferences: {
      nodeIntegration: true
    }
  })

  mainWindow.setMenu(null)
  mainWindow.loadURL(process.env.APP_URL)

  mainWindowState.manage(mainWindow)

  mainWindow.on('closed', () => {
    mainWindow = null
  })
}

app.on('ready', createWindow)
kburns2kb commented 1 year ago

Experiencing this issue

edamlmmv commented 7 months ago

You need to mention the .json file where to remember the values.

mainWindowState = windowStateKeeper({ file: 'mainWindowState.json', defaultWidth: ? defaultHeight: ? });