-
Notifications
You must be signed in to change notification settings - Fork 911
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
stdweb support for eventloop 2.0 #797
Conversation
Everything typechecks, but nothing is implemented
Ok, so I've made a bunch of progress on this (most of it was just churning through various bad designs that didn't work at all) and it's in a state where you can make a window, run an event loop, and receive events! 🎉 I made a roadmap in the PR text to give an indication of where I'm at on the implantation, and the unresolved questions I have about the design. If any maintainers (or users for that matter) have opinions, please let me know! |
Apologies if this question is naive, but would it make sense for winit to support wasm-bindgen's web-sys directly, rather than stdweb? According to this thread, stdweb plans to become a wrapper around web-sys that's a bit higher level (but also more expensive), while web-sys provides the bare minimum only-pay-for-what-you-use interface for Web APIs. Either way, it would be fine to support both, or stdweb now and web-sys later, so I don't mean to imply the PR should be blocked over this. |
Essentially: stdweb is what I'm more familiar with and what my downstream project uses. I would be open to supporting both (for example the rand crate allows either via feature flags) if someone else contributes the web-sys backend. |
General thoughts on the API questions you have:
I'd agree with that for now. We can revisit this once we figure out #696, but for now only having a single canvas is simplest.
Yes, and I'd say to actually make the canvas fullscreen. This is a feature that's commonly supported across browsers (video fullscreening, for instance), it's useful to have, and it's consistent with the other backends.
Eeeeh, I'm less sure about this. If we do end up supporting multiple canvases at some point there's no clean solution for what to do when multiple icons get set on different
I'd say no for now. Using the same File API across both desktop platforms and web platforms implies that the data they provide can be used the same way, which doesn't seem to be the case (I'd be surprised if |
Just a heads up: my progress on this is going to slow down for a while, as I'll probably not have as much time to work on it for the next few weeks. |
After a little testing, it's looking like the basic canvas creation and event handling seem to be working (at least with a slightly generous definition of "working") with the While I'm thinking about it, I've got a couple of thoughts I've been considering:
|
@ryanisaacg Are you intending to maintain the stdweb backend after this PR lands? |
@zegentzy Yes, but without a guarantee that I'll have a lot of time for it. I'll do my best to keep it updated, though; at the very least I'll be using it downstream. |
Okay. Should prolly add a new column and row to the table in https://github.com/rust-windowing/winit/blob/master/CONTRIBUTING.md then. Also to the tables in https://github.com/rust-windowing/winit/blob/master/FEATURES.md when you are done. @Osspial can probably add you to rust-windowing |
examples/window.rs
Outdated
|
||
event_loop.run(|event, _, control_flow| { | ||
println!("{:?}", event); | ||
console!(log, format!("{:?}", event)); |
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.
You might want to revert the changes in this file.
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.
Yup, before merge I'll be doing some cleanup (this is still actively in development and I use this example to test.)
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 great! Let me know if I can help!
I am currently working on unifying both the In summary, I have created a new The The Additionally, I have made some other changes:
Let me know what you think! |
@hecrj: I haven't looked through your changes thoroughly, but I'm thrilled to learn that it's working (particularly with Have you happened to look at the changes in #845? If I recall correctly, they had already started on multi-canvas support, and the That raises a question about |
(Just noticed that this is a Draft PR that I didn't know about previously. Quick intro with very helpful screenshot here: https://github.blog/2019-02-14-introducing-draft-pull-requests/) |
I see that #845 uses platform-specific builder attributes to take control of an already existing canvas in the document. Maybe we could take this approach and simply make the
Not sure what the desired behavior is in this case, but the current one reports mouse events just fine even when the canvas loses focus. Right now, the only events that are focus-dependent are keyboard events. |
@ryanisaacg As we discussed on Discord, I've made a new web branch with @hecrj's fork. It should be noted that it was four commits behind your branch, so you might want to push those changes to it, if they are still applicable. Anyways, closing. Thanks! |
@ryanisaacg Can you open a tracking issue with the things at the top? Thanks. |
Unresolved design questions:
File
object which isn't as useful as it is on desktopImplementation:
Testing / docs:
CHANGELOG.md
if knowledge of this change could be valuable to users