-
Notifications
You must be signed in to change notification settings - Fork 940
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_active
#2585
Add WindowBuilder::with_active
#2585
Conversation
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'm fine with the change, however we should solve the focusing on startup issue first. Given that you don't add any new events, I'd assume that you rely on window being focused.
See this issue
#1077
I'd advise to add a synthetic event(Basically send Focused(false)/Focused(true) where it makes sense) on platform where window is focused/unfocused by default.
By default we should also state that the window is unfocused.
I think on all platforms, a newly spawned window always gains focus, and this method mainly exists to stop that behavior which is useful for a widgets/overlay app where you don't necessarily need focus and merely want to show the window on Top with some content.
I am okay with synthesizing a Focus event, should that be implemented in another PR or in this one?
I think the opposite is true, no? a window by default gains focus, unless |
That's not true, on Wayland the window is unfocused by default, we have a workaround for that. For X11 it could be the same actually, and I think on macOS as well. On macOS you should be under certain conditions though.
The default should be false, since unmapped window isn't focused. What happens when you try to create a new window while being in a full-screen mode? I think in that case new window will be unfocused and in the background, no?
I think the only option is to synthesis the |
Looking at #1077, using winit's master branch, I get the correct events order on Windows that matches x11 here #1077 (comment) so I guess no work needed on those two platforms. |
So what I think we should do is to:
So if the new window is always focused then you send explicit focus, if it's not focused on start or may not be focused you send unfocused, but be careful here, since we don't want to end up unfocused. @madsmtm do you know the focus situation on macOS on start? I'd assume it's always focused, no? So we'd need an explicit focus. |
If I understand this correctly the flow should be:
|
For the one that is focused by the os. But yes, something like that. If you can guarantee that Os will send |
I tested on Windows and according to this comment #1077 (comment) for X11 , that seems to be the current behavior and you said that Wayland synthesize this so only macOS is left which I cannot test. |
8f7c4e0
to
4fa2925
Compare
@madsmtm ping wrt macOS. |
The window is assumed to be unfocused by default, so if we need to match the other platforms here, we should emit a |
I've pushed a fix that does this now |
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 looks fine to me.
(Note that, like many things, it won't work on macOS if done outside the event loop, see the readme. But that's fine for now).
6d5cc89
to
d26c160
Compare
I've retested on X11 and it wasn't like that. Though, I've pushed a fix for that. Be aware that we can't use |
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've added X11 impl and slightly changed the docs for the with_active
. Should be good now.
2d03de2
to
714a503
Compare
714a503
to
e1db81c
Compare
e1db81c
to
db71a49
Compare
CHANGELOG.md
if knowledge of this change could be valuable to usersPorting tauri-apps/tao@e42ff07
Fixes #2580