-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implemented focus_window
#1944
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
Implemented focus_window
#1944
Conversation
|
This is a continuation on #1767, which I've accidentally removed and was unable to recover. @ArturKovacs, you should be able to push your changes now. Sorry for the delay! |
|
Not a problem, these things happen especially with PRs that are left open for long. I'll fix the conflicts as well while I'm at it |
src/platform_impl/macos/window.rs
Outdated
| #[derive(Default)] | ||
| pub struct SharedState { | ||
| pub resizable: bool, | ||
| pub visible: bool, |
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 gets default initialized to false it seems
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.
Yes you are right! After fixing this, it works for me! I just jumped to assuming that it was my system at fault after the fact that the other PR didn't work either.
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.
I just pushed the fix; it seemed easiest to do so.
|
Actually I gave it another thought and realized that it's probably best if the visibility is queried through a system API instead of trying to keep track of it ourselves. There are basically two things that free CI services struggle with: |
ArturKovacs
left a comment
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.
Approving for macOS and X11
msiglreith
left a comment
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! Works fine on Windows as well 👍
Fixes #1750
Window::focus_windowbrings the window to the front and sets input focus to that window. As described in the documentation, this method steals focus from other applications and should be used with care. Even though this method can cause quite a disruptive user experience I do believe winit should provide the option to users of this crate as valid use cases exist. Once #1764 has been merged, documentation could be expanded to redirect users torequest_user_attentionfor a less disruptive way of getting attention to a window.Decided to call it
focus_windowbut the name could be changed for more clarity. Some APIs, likeset_minimized, have a boolean parameter for toggling the, in this case, "minimized" state. Forfocus_windowI decided not to do that as "unfocusing" is quite strange, like, where does the focus go? Also deliberately made the choice to "ignore"focus_windowon minimized and not visible windows for improved user experience.Don't have a Linux X11 machine at my disposal so the implementation might/is probably incorrect.
cargo fmthas been run on this branchcargo docbuilds successfullyCHANGELOG.mdif knowledge of this change could be valuable to users