bevy_winit(emit raw winit events)#15884
Conversation
cefe74a to
0606734
Compare
BenjaminBrienen
left a comment
There was a problem hiding this comment.
Only a tiny nit! Just change one of them (whichever doesn't follow the typical usage).
5c840be to
1725d7a
Compare
1725d7a to
234ea54
Compare
|
I rebased to hopefully get the CI fix for mac os screenshots |
234ea54 to
602727d
Compare
tychedelia
left a comment
There was a problem hiding this comment.
Not so sure that just doing a plain copy is the best way, esp since 99% of users won't use this, but I did just run into a situation with egui as well that requires the underlying winit events.
Thanks for the review. I acknowledge that indeed most users would not and probably should not use this. But it can be a powerful escape hatch as many 3rd party packages take raw egui events as input. |
|
Another alternative would be to provide a way to convert bevy events back into winit events. I'm doing this in my project and it seems to work okay, although is a lossy process w.r.t. some of the original event information. |
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
# Objective - Exposes raw winit events making Bevy even more modular and powerful for custom plugin developers (e.g. a custom render plugin). XRef: bevyengine#5977 It doesn't quite close the issue as sending events is not supported (or not very useful to be precise). I would think that supporting that requires some extra considerations by someone a bit more familiar with the `bevy_winit` crate. That said, this PR could be a nice step forward. ## Solution Emit `RawWinitWindowEvent` objects for each received event. ## Testing I verified that the events are emitted using a basic test app. I don't think it makes sense to solidify this behavior in one of the examples. --- ## Showcase My example usage for a custom `egui_winit` integration: ```rust for ev in winit_events.read() { if ev.window_id == window.id { let _ = egui_winit.on_window_event(&window, &ev.event); } } ``` --------- Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
…rce (#18644) # Objective - In the latest released version (15.3) I am able to obtain this information by getting the actual `EventLoop` via `non_send_resource`. Now that this object has (probably rightfully so) been replaced by the `EventLoopProxy`, I can no longer maintain my custom render backend: https://github.com/HugoPeters1024/bevy_vulkan. I also need the display handle for a custom winit integration, for which I've made patches to bevy before: XREF: #15884 ## Solution - Luckily, all that is required is exposing the `OwnedDisplayHandle` in its own wrapper resource. ## Testing - Aforementioned custom rendering backend works on this commit. --------- Co-authored-by: HugoPeters1024 <hugopeters1024@gmail.com>
…rce (#18644) # Objective - In the latest released version (15.3) I am able to obtain this information by getting the actual `EventLoop` via `non_send_resource`. Now that this object has (probably rightfully so) been replaced by the `EventLoopProxy`, I can no longer maintain my custom render backend: https://github.com/HugoPeters1024/bevy_vulkan. I also need the display handle for a custom winit integration, for which I've made patches to bevy before: XREF: #15884 ## Solution - Luckily, all that is required is exposing the `OwnedDisplayHandle` in its own wrapper resource. ## Testing - Aforementioned custom rendering backend works on this commit. --------- Co-authored-by: HugoPeters1024 <hugopeters1024@gmail.com>
Objective
XRef: #5977
It doesn't quite close the issue as sending events is not supported (or not very useful to be precise). I would think that supporting that requires some extra considerations by someone a bit more familiar with the
bevy_winitcrate. That said, this PR could be a nice step forward.Solution
Emit
RawWinitWindowEventobjects for each received event.Testing
I verified that the events are emitted using a basic test app. I don't think it makes sense to solidify this behavior in one of the examples.
Showcase
My example usage for a custom
egui_winitintegration: