-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Window::has_focus
#2531
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 Window::has_focus
#2531
Conversation
madsmtm
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, looks good, only a few minor nits.
|
I think it's dangerous to add this with blanket |
|
Unfortunately, I don't have much experience with other platforms so I can't implement them, however I may be able to implement x11 if you steer me into the right direction. |
|
@amrbashir I mean it's not about knowing though. You can see where we sent There're no platform specifics at all in the end. |
|
cool, thought there might be a way to query the OS like macOS impl for example. |
|
Maybe on X11, but be aware that active window isn't keyboard focused window sometimes, since you can hover the window with mouse and it'll be active, but won't have focus. |
|
alright, x11, wayland and web, are implemented now but I was not able to test wayland. |
Window::has_focusWindow::has_focus
754075f to
fd1ffc3
Compare
kchibisov
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.
While there's a way to know whether the window is focus or not on ios/Android, I guess the issue was that it's unclear how to hook into the current handlers, which is sort of understandable.
Would leave that to android and ios maintainers.
| max_inner_size: None, | ||
| resize_increments: None, | ||
| base_size: None, | ||
| has_focus: true, |
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.
Shouldn't this be false?
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.
doesn't the window start initially with keyboard focus?
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.
On macOS, the window is initially not focused (and window.has_focus() returns false), but it receives a WindowEvent::Focused shortly after launching (which also makes window.has_focus() return true)
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 only affects x11, on macOS we query the OS directly. The reason I made x11 start with true is because Windows also starts with true and I think x11 is very similar to Windows in this matter, but I haven't had the chance to test x11 (I may test it later today).
|
Android and iOS are now implemented, although I am not sure if a global state on Android is the way to go. |
kchibisov
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.
LGTM.
Would like to hear from android maintainers wrt the change and tracking
focus in a global state. @MarijnS95 or @msiglreith.
Also, you'd need a rebase, I guess.
|
Android can support multiple windows (called EDIT: I haven't checked what the right/updated way is to do this since #2444. |
I am aware of that but glancing over the code, the events are dispatched with a dummy window id and there is no way to differentiate between different activity events. |
|
That's unfortunate to hear @amrbashir, I thought @rib's solution in #2444 would implicitly address this; or at least his crate opens the door for multi-window (multiple Regardless, I thought at least in the past we had a per-window |
madsmtm
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.
Haven't tested the iOS impl, but is very trivial, so accepted from my side. macOS also looks good, thanks for your work @amrbashir!
|
@amrbashir could you rebase it? |
|
Should be fine now |
476f0cc to
3798762
Compare
CHANGELOG.mdif knowledge of this change could be valuable to usersPorting tauri-apps/tao@7d2eeee