-
Notifications
You must be signed in to change notification settings - Fork 920
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
Make EventLoopWindowTarget<T>
independent of the user event type T
#3053
Comments
This would be nice for #3014. The generic type makes it difficult to use the distributed function pointer strategy for event handling that I use in that PR. |
initially, in this comment, I thought the Windows backend is doable but might take some efforts. after I played a little bit with the Windows backend, it turns out way easier than I thought. I managed to get rid of the generic type T in there's two commits in the patch, because I was expecting the changes would be very large and I want to make check points after each small step. I did a quick |
Nice! Could you put up a Pull Request? That makes it easier to review and discuss the changes |
sure, #3061 is created. this is slight different from the patch I posted above, even fewer changes to the existing code, I also added more comments explaining why I did it this way. it's intentionally to be minimum as I'm not very familiar with the code base, but can serve as a start point. |
Unfortunately this isn't going to be easy on Web, but I have started working on it now. |
I'm not sure how it'll work long term for the Wayland, if I move all the winit state into the In general, we could always fallback to dynamic dispatch for the user events, hence winit doesn't need to know what is coming in them, it just needs to pass them around. |
I don't know much about the history of API evolution, the initially I was under the impression that all windows must be created before entering the event loop. the introduction section of the document doesn't mention Lines 52 to 54 in bb9b629
when I first discovered the
from that I assumed it was probably related to some weird API limitations, and maybe OS limitations too (e.g. GUI must be done on main thread, etc). from the high level API of
there's some major difference between my mental model and how it was actually implemented. for example:
|
@daxpedda I just looked at the web backend, and applied my Windows backend technique to it, and it seems doable. here's a little proof-of-concept patch if you want to take a look (I literally just applied my method for the Windows backend to the web to see if it compiles, and it seems it compiles fine) EDIT: I explained the rationale about why I change the code in this way in #3061, it's merely a start point to isolate the user type dependent and independent portion so later cleanups can be done incrementally. DISCLAIMERI'm not a web developer, I don't understand how the web backend works, this is me just trying to proof the |
Nice, that's a really neat idea @nerditation. Thanks! |
@nerditation actually one more thing to add: Ideally you shouldn't create windows with the
Because we want it to integrate well with the platform's native waiting mechanism, as well as emit If we didn't want to do any of that, we could just not have the functionality at all, and let the user use a channel themselves.
Might be possible, biggest blocker is that it'll take quite a bit of work. |
Web is done now. |
Requested in #2900 (comment).
Should be possible from an API perspective, though might be a bit tricky to change in the backends.
Platforms that just use
PhantomData<T>
in the type (and thus don't need the actual user event type):EventLoopWindowTarget
independent of the user type on Redox/Orbital #3055T
fromEventLoopTargetWindow
#3081EventLoopWindowTarget
independent of UserEvent type #3061Finish:
T
fromEventLoopWindowTarget
#3298The text was updated successfully, but these errors were encountered: