GithubHelp home page GithubHelp logo

Comments (5)

ixaxaar avatar ixaxaar commented on May 25, 2024 1

Same here, specifying custom path or file prevents saving state. Also state is only saved on closing the app,

To fix this issue I took this code and modified it to my linking and it works well (for me).

I also added a win.on('resize', saveState); to save state on every resize event.

from electron-window-state.

Christilut avatar Christilut commented on May 25, 2024 1

Thanks, setting it manually does seem to work:

  win.on('resize', debounce(mainWindowState.saveState, 500))
  win.on('move', debounce(mainWindowState.saveState, 500))

Leaving the issue open because seems the default way with .manage() is broken

from electron-window-state.

codingedgar avatar codingedgar commented on May 25, 2024

In my case the state is not persisted between updates of the app, I'll try the resize | move and see if it works better.

from electron-window-state.

raine avatar raine commented on May 25, 2024

I had to do:

const debouncedSaveWindowState = debounce(
  (event: any) => mainWindowState.saveState(event.sender),
  500
)
                                                           
mainWindow.on('resize', debouncedSaveWindowState)
mainWindow.on('move', debouncedSaveWindowState)

@Christilut's code assumes that the window is sent as argument to mainWindowState.saveState, but in my electron, it would get an object where sender property is the actual window.

from electron-window-state.

JaosnHsieh avatar JaosnHsieh commented on May 25, 2024

It works persistently on Windows and Mac on my side after I changed the defaultHeight to 600.

On my windows laptop this condition state.y + state.height <= bounds.y + bounds.height would always be false if I set defaultHeight to 768.

from electron-window-state.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.