Repository navigation
Read and set a window's position and size - #38
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For a program that reopens its windows where they were:
x()/y()give the top left of the current window's frame, in logical pixels from the top left of the main display.set_position(x, y)moves the frame there, unless nothing of it would show on a display (a display that was unplugged since). On macOS the displays come fromNSScreen.screens: winit'savailable_monitors()came back empty here, becauseCGGetActiveDisplayListfailed. Elsewhere they come from winit.set_size(w, h)sizes the drawable. On macOS the size changes at once with noResizedevent, so the new size is recorded, the surface reconfigured, andresized()reports it.Checked on macOS with two displays: a window moved to (120, 140) and sized to 500x260 reads back as 120,140 at 1000x520 physical. Moving it to (-99999, 140) leaves it in place. Moving it to (-100, -1000) puts it on the display above.