refactor: sdl3::events - Modernize/Update SDL3 Events#258
Conversation
|
Thank you! Happy to look/merge when CI is passing 😄 |
|
Yep, working on it, I missed some of them because of the feature flags |
|
I am considering adding a lifetime to events so that we can avoid cloning into Strings. If we add a lifetime bound to the event pump, since SDL handles backing memory we should be gracefully be able to just have Since a vast majority of the events don't have string references, the inner types should be trivially copyable anyways if you really need a copy. This would facilitate better to_ll/from_ll behavior, but I'm wondering if we really need to_ll still... |
|
Okay, please let me know when this PR is ready to merge. Do you want to add lifetimes here or later? |
|
The direction here is right: grouping the flat SDL variants into structs with state enums mirrors how SDL3 itself models events, and the added accessors ( The problem is it's drifted a long way from master. The branch predates several event changes that have since landed ( Could you rebase onto current master and fold those back in? Given the size and that it's a breaking change, it'd also be far easier to review (and to land as a major-version bump) if the core enum restructure were split from the example/test migration. Keen to get this in once it's caught up. |
Hi, while using migrating from winit to SDL3, I noticed that some of the events strangely did not have all of the correct fields and names (In my particular case, I have multiple windows and many of the events were missing
window_id).Seeing as some of these events haven't been updates in years from their source, I went ahead and modernized the events a bit. Thankfully, as you can see in the examples, their replacement/updated usage is pretty easy to follow.
Key changes:
SDL_Event(where feasible).Eventso external code continues to referencecrate::event::Event.get_timestamp,get_window_id,is_*classifiers).