Remove lifetime from Event type#1456
Conversation
|
Nice PR! I don't think that performance is that important. How often does the DPI change? I'd say it's quite rarely. A Also it would be cool if you could re-add the Clone impls for Event. |
|
I don't thing perf is a big concern at all, DPI can change at most a few times a second (afaik, zooming in/out on the web is the quickest way to change DPI, but that support isn't yet implemented in winit). I'd like to get @Osspial's and @goddessfreya's opinions about this change, the key difference between this and the bottom row of #939 (comment) is that this does not expose the |
|
Thanks for taking the time to address this @tangmi! I've been updating |
|
@mitchmindtree absolutely if this PR doesn't do it, I'll file a PR myself to re-add the Clone impls. |
|
@mitchmindtree My understanding is that |
Users can still do that with this implementation with or without |
|
(I wasn’t a part of the original event loops 2.0 discussions so I’m a bit clueless here)
Whether or not Event should be Clone is probably out of the scope of this PR, but it may be worth creating an issue (if there’s not already) discussing the concrete use cases of having it Clone, since there might be a nice solution that even better handles the intended use cases. |
f07fe27 to
5b6e9a0
Compare
|
Update:
|
|
@goddessfreya: While this PR isn't ready to review, but I would love your thoughts on the concept (replace the lifetime with interior mutability) to see if it's something we'd consider pursuing! Edit: I just saw your status message, hope you are feeling better soon! |
Osspial
left a comment
There was a problem hiding this comment.
Hey, thanks for drafting this PR up. Sorry it's taken such a long time for me to get to reviewing it.
I think this is the right direction to move Winit, and I agree that the performance impact of using an Arc for this is small enough to be ignored. I've got some feedback on how NewInnerSizeInteriorMutCoolThing should be exposed, but I think the rough semantics of this PR's API are sound.
|
@Osspial no worries at all for the response times! I know we're all busy (and the world is especially weird right now!). I'll need to take some time myself to re-review this changelist to remember what I was doing and clean it up. If my "todo" list is accurate, I need to finish the remaining platforms, and do some bookkeeping/docs/tests. |
69c3010 to
0017517
Compare
|
@Osspial: turns out most of my changes was just the "interior mut cool thing", which you've greatly improved. Latest changes:
I'll try and work my way through the various backends, may need some help with e.g. android (or permission to spam you with github actions emails) |
…' into remove-lifetime-from-event-proto
|
This happened a lot quicker than I was expecting! Some open questions:
I'm going to mark this as 'ready to review', but I'm also still curious about @goddessfreya 's thoughts :) |
That's a good point. Now that you mention it, we should probably keep
That's something we should address, yeah. I haven't been running Clippy on my system, but there are probably some hidden bugs lying throughout the Winit codebase that it'd catch.
👍 |
|
@Osspial On macOS, On Windows, the winit/src/platform_impl/windows/event_loop.rs Line 1717 in 03335ce may happen synchronously or asynchronously, if the Edit: I think there might be an opportunity to move the "post scale-factor-changed event resize handler" code into |
|
This PR would be very usefull if it could be merged. This event life time is a pain. |
|
I'm running into this trying to do input playback for Bevy. How can I help move this forward? |
|
@alice-i-cecile you may be able to use |
|
Yep, that's the workaround I'm using for now :( It's not great, but it's better than writing my own enum type that has all the variants except one. |
|
@alice-i-cecile this PR has gotten quite stale and probably needs a rewrite given the ~2.5 years that have elapsed and things have certainly changed. It's probably worth bumping #1387 and working with @madsmtm (a current member of rust-windowing) to come up with a design. |
|
Great, thanks for the heads up. I ended up using a different approach for now (mocking inputs at a higher level of abstraction), but if I end up running into this again I'll take a look there. |
|
Replaced by #2981 |
Arc<Mutex<T>>(I'm unsure of the exact implications here!)cargo run --example dpiand changing the Windows DPI settings while it is running (I'm unsure of the intended behavior, but the state seems to be set correctly!)Eventmay not even be what we want!todo:
scoped_arc_cellcargo fmthas been run on this branchcargo docbuilds successfullyCHANGELOG.mdif knowledge of this change could be valuable to users