-
Notifications
You must be signed in to change notification settings - Fork 891
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
Add WindowBuilder::with_outer_position #1866
Add WindowBuilder::with_outer_position #1866
Conversation
16984d0
to
3ba3be9
Compare
I combined all the changes into a single commit on top of master. Let me know if I should first update this branch, or if I should open PR against master. |
Why does this simple PR have 153 files changed? It's impossible for anyone to sort through this. |
e00cba5
to
465d653
Compare
Changed base to master, added contributors, fixed X11 (I can't |
5a979aa
to
58e6f94
Compare
It seems like GitHub won't accept your co-author assignments. Try this instead:
PS: Osspial is no longer a mainainer for Windows. @msiglreith is the one you want for now. |
src/platform_impl/macos/window.rs
Outdated
let (left, bottom) = match attrs.outer_position { | ||
Some(position) => { | ||
let logical = window_position(position.to_logical(scale_factor)); | ||
// macOS wants the position of the bottom left corner, | ||
// but caller is setting the position of top left corner | ||
(logical.x, logical.y - height) | ||
} | ||
// This value is ignored by calling win.center() below | ||
None => (0.0, 0.0), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for me. When I create two windows and set the height of both to 50 and set the y coordinate of one of them to 50, using with_outer_position
and set the y coordinate of the other to 50 using set_outer_position
, both windows should be at the same y coordinate. But this is what I get:
I believe you forgot to include the menubar height in your calculations here. You might need to create the window first and then set the position for the existing window. This might help: https://stackoverflow.com/questions/28955483/how-do-i-get-default-title-bar-height-of-a-nswindow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unlikely to be solvable. Creating window and then setting its position breaks the whole point of this feature, which is to avoid the flickering when creating a window and then repositioning it.
I'm also not sure which position is wrong one, whether this one or the one in set_outer_position.
I could see if I could hardcode the title bar height perhaps to fix the wrong one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing or hardcoding the title bar height is unlikely to work, due to macOS UI changes like this:
https://www.reddit.com/r/MacOSBeta/comments/hq00ll/insane_titlebar_height_and_question_on_logical/
I think we'll have to settle on documenting that this method sets "inner" position on MacOS, despite its name, due to platform limitations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep we should definitely not hardcode or guess the menubar height when the function name promises to set the outer position. For the same reason I don't think we should just set the inner position when the function is called with_outer_position
. But I agree that it would be nice to have at least some way to set the startup position. So at this point the only thing I have problem with is the function name. I think calling it with_approx_position
or something similar would be completely fine. And the documentation should of course describe what this means for each platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @msiglreith @murarth?
Co-authored-by: Osspial <osspial@gmail.com> Co-authored-by: Murarth <murarth@gmail.com>
58e6f94
to
b1122ae
Compare
… with_outer_position
Ready for re-review fyi @ArturKovacs @msiglreith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, lgtm (Windows).
The default Win10 theme has some invisible borders which result in some minor offsets (7/8pts) of the visibile position. But not too important imo.
…not be exactly outer or inner position
This should be ready for merging btw. cc @ArturKovacs |
src/window.rs
Outdated
/// **Windows**: Borders might be shown outside the set position, so the position is | ||
/// approximate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should specify what kind of position it is, and to me, the wording is a bit hard to understand. I suggest
"The outer position. In other words, the top left corner of the title-bar. There may be a small gap between this position and the window due to specifics of the Window Manager"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not yet addressed
/// The desired position of the window. If this is `None`, some platform-specific position | ||
/// will be chosen. | ||
/// | ||
/// The default is `None`. | ||
/// | ||
/// ## Platform-specific | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Platform-specific list should be formatted as a list, that is each item beggining with a -
like this:
- **macOS**: ...
- **Window**: ...
Also under Platform-specific, you should describe the kind of position this means on all of the platforms. For example
- **X11**: The outer position.
- **Others**: This is ignored.
I know I'm being unusually picky, but it's mostly because this one functionality does different things on different platforms, so I just want to make sure that whoever comes across this will have no confusion about what it does. Furthermore considering that the name of a public function and a public field has changed, I believe @msiglreith and @murarth need to approve this before it can be merged. |
Isn't this PR purely additive when compared against master? |
What I meant was that there were changes in the API since those maintainers approved therefore their approval doesn't apply to the current state. |
Fine for me once the latest comments by @ArturKovacs have been addressed. |
Addressed @ArturKovacs's comments. |
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to usersI think this finishes the important platforms and we could actually merge the branch to master?
cc @murarth @Osspial