Fix window position on MacOSX #2677
Merged
+76
−40
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.
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
CKAN/GUI/Configuration.cs
Line 43 in aba8b02
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 theWindowLoc
property is removed.Now if
Configuration.WindowLoc
is -1,-1, we don't bother restoring it but instead setStartPosition
toCenterScreen
, 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 theUtil
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 likeClampedLocation
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.