-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add WakeUp event to App #19212
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
base: main
Are you sure you want to change the base?
Add WakeUp event to App #19212
Conversation
7b03840
to
98f0449
Compare
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 look right to me. From what I can tell the problem isn't that the WakeUp
event registration is missing. It's that WakeUp
derives Event
but it's not actually used as a Bevy event. Instead it's dispatched directly to winit using EventLoopProxy::send_event
.
I think instead either the Event
derive needs to be removed for WakeUp
or there should be a system that redispatches the events like:
fn redispatch_winit_event<E = Event>(
mut events: EventReader<E>,
event_loop_proxy: Res<EventLoopProxyWrapper<E>>,
) {
for event in events.read() {
let _ = event_loop_proxy.send_event(event.clone());
}
}
And then in the WinitPlugin<T>
builder it would add a redispatch_winit_event<T>
system to the schedule.
So, the reason I made this PR is that we have code at work that uses that Looking at this more, it probably makes more sense to just remove the Event constraint on WakeUp since that doesn't seem to be the intended usage of it. |
Okay, looking at the code more. I think I found where the send_event happens. It's inside I don't know why that feature exists but I think doing that So, with that taken into consideration, if we don't want to change/break any existing behaviour, we can't remove the derive and we can't add the redispatch system. |
I did more digging and I think I figured out what happened. The #15649 PR added a feature flag on this line https://github.com/bevyengine/bevy/pull/15649/files#diff-b7a9bee1adef16186c0b38f7f0d7969565519dba556c0ecd007632ac35725cf5L91 the feature flag was only about the cursor part but it was also added to the add_event which I believe should not be behind a feature flag. That would explain why our usage of this broke in 0.15 but was fine in 0.14. So the fix seems to be to only add the feature flag on the appropriate part of that line instead of that entire line. I'll push this fix on this branch and see what people think. |
98f0449
to
1811de2
Compare
Oh right that makes sense now. My suspicion is that the |
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.
Looks good.
It seems to me that there's no need for the WakeUp
event, the type params on WinitAppRunnerState
and WinitPlugin
, or the user_event
impl at all but cleaning any of that up isn't urgent.
Objective
Solution
Testing