2020-04-06 03:19:02 +00:00
|
|
|
[package]
|
|
|
|
name = "bevy_winit"
|
2023-07-10 21:19:27 +00:00
|
|
|
version = "0.12.0-dev"
|
2021-10-27 00:12:14 +00:00
|
|
|
edition = "2021"
|
2020-08-10 00:24:27 +00:00
|
|
|
description = "A winit window and input backend for Bevy Engine"
|
|
|
|
homepage = "https://bevyengine.org"
|
|
|
|
repository = "https://github.com/bevyengine/bevy"
|
2021-07-23 21:11:51 +00:00
|
|
|
license = "MIT OR Apache-2.0"
|
2020-08-10 00:24:27 +00:00
|
|
|
keywords = ["bevy"]
|
2020-04-06 03:19:02 +00:00
|
|
|
|
2020-08-25 00:06:08 +00:00
|
|
|
[features]
|
2022-11-14 23:08:31 +00:00
|
|
|
trace = []
|
2023-05-31 16:48:03 +00:00
|
|
|
wayland = ["winit/wayland", "winit/wayland-csd-adwaita"]
|
2020-08-25 00:06:08 +00:00
|
|
|
x11 = ["winit/x11"]
|
2023-07-08 22:31:30 +00:00
|
|
|
accesskit_unix = ["accesskit_winit/accesskit_unix", "accesskit_winit/async-io"]
|
2020-08-25 00:06:08 +00:00
|
|
|
|
2020-04-06 03:19:02 +00:00
|
|
|
[dependencies]
|
2020-08-10 00:39:28 +00:00
|
|
|
# bevy
|
2023-07-10 21:19:27 +00:00
|
|
|
bevy_a11y = { path = "../bevy_a11y", version = "0.12.0-dev" }
|
|
|
|
bevy_app = { path = "../bevy_app", version = "0.12.0-dev" }
|
|
|
|
bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" }
|
|
|
|
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" }
|
|
|
|
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0-dev" }
|
|
|
|
bevy_input = { path = "../bevy_input", version = "0.12.0-dev" }
|
|
|
|
bevy_math = { path = "../bevy_math", version = "0.12.0-dev" }
|
|
|
|
bevy_window = { path = "../bevy_window", version = "0.12.0-dev" }
|
|
|
|
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
|
|
|
|
bevy_tasks = { path = "../bevy_tasks", version = "0.12.0-dev" }
|
2020-04-06 03:19:02 +00:00
|
|
|
|
2020-08-10 00:39:28 +00:00
|
|
|
# other
|
2023-10-02 00:37:03 +00:00
|
|
|
winit = { version = "0.28.7", default-features = false }
|
2023-07-08 22:31:30 +00:00
|
|
|
accesskit_winit = { version = "0.14", default-features = false }
|
Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7 (#6218)
# Objective
- Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7.
## Solution
---
## Changelog
### Changed
- Changed `RawWindowHandleWrapper` to `RawHandleWrapper` which wraps both `RawWindowHandle` and `RawDisplayHandle`, which satisfies the `impl HasRawWindowHandle and HasRawDisplayHandle` that `wgpu` 0.14.0 requires.
- Changed `bevy_window::WindowDescriptor`'s `cursor_locked` to `cursor_grab_mode`, change its type from `bool` to `bevy_window::CursorGrabMode`.
## Migration Guide
- Adjust usage of `bevy_window::WindowDescriptor`'s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`.
2022-10-19 17:40:23 +00:00
|
|
|
approx = { version = "0.5", default-features = false }
|
|
|
|
raw-window-handle = "0.5"
|
2020-09-16 20:40:32 +00:00
|
|
|
|
2023-02-03 16:41:39 +00:00
|
|
|
[target.'cfg(target_os = "android")'.dependencies]
|
2023-10-02 00:37:03 +00:00
|
|
|
winit = { version = "0.28.7", default-features = false, features = [
|
|
|
|
"android-native-activity",
|
|
|
|
] }
|
2023-02-03 16:41:39 +00:00
|
|
|
|
2020-09-16 20:40:32 +00:00
|
|
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
2020-09-21 23:12:34 +00:00
|
|
|
wasm-bindgen = { version = "0.2" }
|
2020-09-19 03:11:26 +00:00
|
|
|
web-sys = "0.3"
|
Optionally resize Window canvas element to fit parent element (#4726)
Currently Bevy's web canvases are "fixed size". They are manually set to specific dimensions. This might be fine for some games and website layouts, but for sites with flexible layouts, or games that want to "fill" the browser window, Bevy doesn't provide the tools needed to make this easy out of the box.
There are third party plugins like [bevy-web-resizer](https://github.com/frewsxcv/bevy-web-resizer/) that listen for window resizes, take the new dimensions, and resize the winit window accordingly. However this only covers a subset of cases and this is common enough functionality that it should be baked into Bevy.
A significant motivating use case here is the [Bevy WASM Examples page](https://bevyengine.org/examples/). This scales the canvas to fit smaller windows (such as mobile). But this approach both breaks winit's mouse events and removes pixel-perfect rendering (which means we might be rendering too many or too few pixels). https://github.com/bevyengine/bevy-website/issues/371
In an ideal world, winit would support this behavior out of the box. But unfortunately that seems blocked for now: https://github.com/rust-windowing/winit/pull/2074. And it builds on the ResizeObserver api, which isn't supported in all browsers yet (and is only supported in very new versions of the popular browsers).
While we wait for a complete winit solution, I've added a `fit_canvas_to_parent` option to WindowDescriptor / Window, which when enabled will listen for window resizes and resize the Bevy canvas/window to fit its parent element. This enables users to scale bevy canvases using arbitrary CSS, by "inheriting" their parents' size. Note that the wrapper element _is_ required because winit overrides the canvas sizing with absolute values on each resize.
There is one limitation worth calling out here: while the majority of canvas resizes will be triggered by window resizes, modifying element layout at runtime (css animations, javascript-driven element changes, dev-tool-injected changes, etc) will not be detected here. I'm not aware of a good / efficient event-driven way to do this outside of the ResizeObserver api. In practice, window-resize-driven canvas resizing should cover the majority of use cases. Users that want to actively poll for element resizes can just do that (or we can build another feature and let people choose based on their specific needs).
I also took the chance to make a couple of minor tweaks:
* Made the `canvas` window setting available on all platforms. Users shouldn't need to deal with cargo feature selection to support web scenarios. We can just ignore the value on non-web platforms. I added documentation that explains this.
* Removed the redundant "initial create windows" handler. With the addition of the code in this pr, the code duplication was untenable.
This enables a number of patterns:
## Easy "fullscreen window" mode for the default canvas
The "parent element" defaults to the `<body>` element.
```rust
app
.insert_resource(WindowDescriptor {
fit_canvas_to_parent: true,
..default()
})
```
And CSS:
```css
html, body {
margin: 0;
height: 100%;
}
```
## Fit custom canvas to "wrapper" parent element
```rust
app
.insert_resource(WindowDescriptor {
fit_canvas_to_parent: true,
canvas: Some("#bevy".to_string()),
..default()
})
```
And the HTML:
```html
<div style="width: 50%; height: 100%">
<canvas id="bevy"></canvas>
</div>
```
2022-05-20 23:13:48 +00:00
|
|
|
crossbeam-channel = "0.5"
|
2021-02-22 04:15:50 +00:00
|
|
|
|
|
|
|
[package.metadata.docs.rs]
|
|
|
|
features = ["x11"]
|