Skip to content
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

Web support tracking issue #1072

Closed
10 tasks done
Tracked by #63
ryanisaacg opened this issue Jul 26, 2019 · 9 comments
Closed
10 tasks done
Tracked by #63

Web support tracking issue #1072

ryanisaacg opened this issue Jul 26, 2019 · 9 comments
Labels
C - in progress Implementation is proceeding smoothly DS - web S - meta Project governance

Comments

@ryanisaacg
Copy link
Contributor

ryanisaacg commented Jul 26, 2019

@ryanisaacg ryanisaacg added DS - web C - needs discussion Direction must be ironed out C - in progress Implementation is proceeding smoothly labels Jul 26, 2019
@goddessfreya goddessfreya added the S - meta Project governance label Jul 26, 2019
@hecrj
Copy link
Contributor

hecrj commented Aug 14, 2019

Before proceeding, I think we need to get on the same page on how to tackle some of these last features.

On-close event listening

How would this work? We need to keep in mind that right now canvases have a "local" scope. We could attach a beforeunload event listener to the window and proxy the event to all the existing canvases. That would be a global thing, so it may be awkward to implement/maintain, and I feel it could lead to weird bugs overall.

Ideally, we should be able to detect if a particular canvas has been "closed". But when do we consider a canvas to be closed? When it's removed from the DOM? That wouldn't work because a user may want to reinsert the canvas and keep using it.

I am not sure there is a reasonable implementation for this. I am inclined to simply state that a canvas cannot be closed, and ask our users to take care of any unload wiring themselves (the same way we ask them to insert the canvas freely).

Support fullscreen APIs
Support maximizing a canvas

These ones are also tricky. Anything that touches global state (i.e. document, window, etc.) will have erratic/unintuitive behavior when dealing with multiple canvases (unless we emulate a window manager ourselves). What should happen if our users try to maximize/toggle fullscreen on multiple canvases on the same page?

I think I would simply let users handle this too. At least for now. Users will be able to make better informed decisions as they will know exactly how many canvases they will be dealing with.

Decide if tab title / favicon should be exposed by some cross-platform extension, treated as window icon and title, or neither

I think this should be left to the users of the API, as we don't currently have a concept of "main" canvas.

@ryanisaacg
Copy link
Contributor Author

@hecrj

On-close event listening

How would this work?

I think that closing events are a part of the event loop contract at least, so we could emit a LoopDestroyed event when the browser tab is being closed. I agree that individual canvases should have no concept of being closed.

Support fullscreen APIs
Support maximizing a canvas

Fullscreen support with n canvases should be fine: the browser interface doesn't give us access to monitors anyway, so we can just fullscreen the canvas whenever a window requests it.

I agree that maximization is trickier, and would be very in favor of Not Bothering. Implementing a WM in the browser is not within scope (hopefully).

Decide if tab title / favicon should be exposed by some cross-platform extension, treated as window icon and title, or neither

I'm inclined to say that we should at least try to solve this. If I create exactly one window, then applying that window's title and favicon to the entire tab makes sense. If I create two, it no longer does. I'm not sure it would be possible to special-case, though.

@hecrj
Copy link
Contributor

hecrj commented Sep 3, 2019

I think that closing events are a part of the event loop contract at least, so we could emit a LoopDestroyed event when the browser tab is being closed.

Sounds good to me 👍

Fullscreen support with n canvases should be fine: the browser interface doesn't give us access to monitors anyway, so we can just fullscreen the canvas whenever a window requests it.

Is there a canvas API to achieve this? As far as I know, we will need to overlay the canvas on top of everything and fix its size to the window.

If I create exactly one window, then applying that window's title and favicon to the entire tab makes sense.

I don't think this is particularly true. One of the main use cases that I want to be able to satisfy with winit is embedding interactive Rust examples in blog posts. Now, a blog post could only have a single example, but that doesn't mean the example should be allowed to mess with the document's title.

I guess we could create an extension trait that allows marking a window as the "main window", but that kind of API will be allowing multiple windows to be marked as main ones and cause title / favicon fighting. Overall, it can make winit on web less composable.

@ryanisaacg
Copy link
Contributor Author

Is there a canvas API to achieve this? As far as I know, we will need to overlay the canvas on top of everything and fix its size to the window.

There's a general purpose Fullscreen API that allows fullscreening a single Element and all its children: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API

I don't think this is particularly true. One of the main use cases that I want to be able to satisfy with winit is embedding interactive Rust examples in blog posts. Now, a blog post could only have a single example, but that doesn't mean it should be allowed to mess with the document's title.

That's a very good point, I now agree that winit should keep away from the title and favicon.

@hecrj
Copy link
Contributor

hecrj commented Sep 3, 2019

There's a general purpose Fullscreen API that allows fullscreening a single Element and all its children: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API

Oh wow! That is a really neat API I had no clue about! Great news. I agree we should take care of it then!

@ryanisaacg
Copy link
Contributor Author

It seems like the only web API that we could use to do something like cursor grab (the Pointer Lock API) also inherently hides the mouse cursor by default, and only sort-of allows something like a cursor grab.

Possibly we can add it as a platform-specific extension, but I think that should be after we merge the web version to master.

@ryanisaacg
Copy link
Contributor Author

There will be a little bit of book-keeping that Winit will have to do for supporting fullscreen properly, which is maintaining the size of the canvas and sending resize events. This shouldn't be too complex so I think it's still a good idea to add support for fullscreen.

@ryanisaacg ryanisaacg removed the C - needs discussion Direction must be ironed out label Sep 20, 2019
@tangmi
Copy link
Contributor

tangmi commented Oct 18, 2019

Awesome work! Is this closed by #1221?

@ryanisaacg
Copy link
Contributor Author

Yup, I've moved the checkbox for web's RedrawRequested API to the tracking issue itself. Since web support has shipped on master, we're good to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - in progress Implementation is proceeding smoothly DS - web S - meta Project governance
Development

No branches or pull requests

4 participants