Consider a state without bounds still valid if fullscreen of maximized #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The state will have it's coordinates and size info updated only if the
app is not in fullscreen mode or maximized at the time of the update.
This makes sense because coordinates and size are not relevant when in
fullscreen or maximized. The problem is that only the defaultWidth and
defaultHeight definitions will be read if the state in the file is not
considered valid, and to be considered valid, a state must have bounds
(x, y, width and height must be defined).
When leaving the application for the first time (no preexistent
window-store.json), if the application was in fullscreen mode or
maximized when exiting, the newly created window-store.json will not
have coordinates and size info (since the update function that is called
right before the save operation will ignore the coordinates and size, as
said before).
Because of that, when the application is opened for the second time, the
state is considered invalid and the saved isMaximized or
isFullScreen options are completely ignored.
This fixes that by considering the state valid if isFullScreen or
isMaximized are true, even if it has no bounds. It also adds some basic
tests to this functionality.
I noticed this problem when I was trying to follow Nyaovim's documentation on it's browser-config.json file and
remember_window_state
wasn't working as expected. I dug a little on Nyaovim's source and eventually found that when theremember_window_state
was set to true, it basically turned onelectron-window-state
. So I started digging here as well initially so that I could open an issue with some useful info instead of a simple "this ain't working".The damn bug ended up being so erratic that it wasn't until I actually found the problem on the code that I understood how to reproduce it and what was really happening. By that time, I figured it was easier to fork the repo and make a pull request. 😄