Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restoration of windows saved state #1511

Merged
merged 2 commits into from
Jun 4, 2022

Conversation

CmP-lt
Copy link
Contributor

@CmP-lt CmP-lt commented Jun 4, 2022

Suggested code changes alter current behavior of window saved state restoration to address the following issues:

  • window saved bounds not being restored when they extend past screen bounds in any direction;
  • divider location of main window's split pane is restored incorrectly when main window state is restored to maximized.

* Don't skip restoration of window saved bounds when they intersect with screen bounds.
* Restore saved bounds of main window regardless of it's saved extended state (fixes divider location of main split pane being restored incorrectly when saved state of main window is maximized).
@skylot
Copy link
Owner

skylot commented Jun 4, 2022

Changes with extended state is fine, but you can't just remove isContainedInAnyScreen method because it was added with a purpose (from PR #521):

This change accepts the stored windows positions only if they are completely inside one of the visible screens, otherwise show it by the default location in the default screen.
The reason of this, if a user changes from two screens to one screen, then he won't be able to see the windows at all.
Ideally, we should check if a part of the window is inside the screen, or if the window is split between two screens, but I don't think this is necessary at this time.

And looks like it is a time to somehow merge these requirements. Maybe also save screens config and if it changes ignore saved position.

@CmP-lt
Copy link
Contributor Author

CmP-lt commented Jun 4, 2022

Ideally, we should check if a part of the window is inside the screen

It does seem that such check is enough to handle all cases in which window saved bounds aren't included in any screen.

Maybe also save screens config and if it changes ignore saved position.

Why would this be needed, assuming the check above is sufficient for handling problematic cases properly? Is it not?

@skylot
Copy link
Owner

skylot commented Jun 4, 2022

@CmP-lt looks good now, thanks!

@CmP-lt
Copy link
Contributor Author

CmP-lt commented Jun 4, 2022

451cc3d adds handling for cases when window saved bounds are outside of all screens by implementing the check described above. isAccessibleInAnyScreen is a new (suitable, I suppose) name for isContainedInAnyScreen method in which Rectangle's contains method is replaced with intersects.

@skylot skylot merged commit 0809993 into skylot:master Jun 4, 2022
@CmP-lt CmP-lt deleted the window-state-restore-fix branch June 5, 2022 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants