OrangeNote / RuneBook

📖 arcane Rune Pages manager for League of Legends 📜
MIT License
94 stars 65 forks source link

Respect last window state (size/position) #33

Closed fdarveau closed 6 years ago

fdarveau commented 6 years ago

This updates the main window's initialization code to remember the window state from the previous time the app was used, using the electron-window-state helper.

This allows the app to remember I put it on my second monitor and open on that second monitor next time instead of having to move it back where it was every time.

Since I have Node 5 installed, the package-lock.json was also created when doing the npm install, so it has been added to source control as well. Feel free to tell me if you prefer to not have it and I will add it to .gitignore and remove the file in my fork.

OrangeNote commented 6 years ago

I'll merge this when I'll fix window height for smaller screens.

In the meantime you can add package-lock.json to .gitignore.

Thank you.

fdarveau commented 6 years ago

Done

fdarveau commented 6 years ago

FYI, just in case you are not on it, you might want to change the minHeight value from this PR to the one you set on the previous commit where you changed it.

OrangeNote commented 6 years ago

Thanks. Yes, I'm still adjusting those values, because I made the rune pages list flexible along y.

One question though: you set minWidth and minHeight slightly above the original values to compensate useContentSize set to false, I guess. But are those values calculated from your OS specific window frame? I see that useContentSize needs to be false for electron-window-state. Originally I needed to set useContentSize to true, because I didn't want the window frame to affect the calculations inside the web page. Now that the content is flex, I might not need that anymore. But I'm worried that if I set arbitrary values (especially for minHeight, minWidth should not be a problem) content will overflow the page.

I'm saying that because I'm on macOS, and on that platform I'm using a frameless window. But now that I think of it, I'll make the window frameless on Windows too, with custom buttons for the window controls (like the league client). schermata 2018-03-16 alle 14 32 02

So no useContentSize issues and no more double header on Windows.

fdarveau commented 6 years ago

Now that you make me think about it, yes, they might be calculated based on the full windows frame, including the frame.

I might have to look more closely at electron-window-state to check that.

Baiscally, I put the minHeight and minWidth to the values that were saved by electron-window-state on first launch. If those values include the frame, it might interfere with the frameless version on macOS as you said.

I'm currently at work, so I can't use much time right now to look into this.

OrangeNote commented 6 years ago

Don't worry, I'll probably sort it out by myself. I repeat, if I set the window frameless on both OSs, there won't be inconsistency between them, and useContentSize won't matter anymore, so we can set it to false, as electron-window-state requires.