Skip to content

Fix window position on MacOSX #2677

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

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

HebaruSan
Copy link
Member

Problem

MacOSX users have experienced problems with CKAN's title bar appearing behind the OS menu bar, such that it cannot be used to move the window.

Cause

private Point windowLocation = new Point(0,0);

That value is used as the window location if the position isn't saved in CKAN/GUIConfig.xml. So the first time you run CKAN, it tries to appear at the upper left corner of the screen.

Changes

Configuration is changed to treat the default window position as -1,-1 instead of 0,0. This is so we can distinguish between the default and values the user might choose (0,0 could be either one). Some other weird workaround stuff around the WindowLoc property is removed.

Now if Configuration.WindowLoc is -1,-1, we don't bother restoring it but instead set StartPosition to CenterScreen, so the GUI window will be centered on the first run.

In #2587 we created a ClampedLocation function that finds a safe location for a box where it's entirely on one screen. That pull request used it for the tray icon popup menu. Now this function is moved to the Util static class, and we also use it when we restore the window position on non-MacOSX platforms. This will ensure that the window is always fully on screen when it appears.

A new Util.ClampedLocationWithMargins function is created that works like ClampedLocation but allows padding around the window to be specified. We use this when restoring the window position on MacOSX, with a 30px top margin and 0px everywhere else. This will ensure that the window doesn't overlap the menu bar on MacOSX.

Fixes #1838.

@HebaruSan HebaruSan added GUI Issues affecting the interactive GUI Pull request macOS Issues specific for macOS labels Jan 31, 2019
@politas politas merged commit 11e04ca into KSP-CKAN:master Feb 1, 2019
politas added a commit that referenced this pull request Feb 1, 2019
@HebaruSan HebaruSan deleted the fix/mac-window-position branch February 1, 2019 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI Issues affecting the interactive GUI macOS Issues specific for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants