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

Update winit version 0.27.3 #6086

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bevy_winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ bevy_window = { path = "../bevy_window", version = "0.9.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.9.0-dev" }

# other
winit = { version = "0.26.0", default-features = false }
winit = { version = "0.27.3", default-features = false }
approx = { version = "0.5.0", default-features = false }
raw-window-handle = "0.4.2"

[target.'cfg(target_arch = "wasm32")'.dependencies]
winit = { version = "0.26.0", default-features = false }
winit = { version = "0.27.3", default-features = false }
wasm-bindgen = { version = "0.2" }
web-sys = "0.3"
crossbeam-channel = "0.5"
Expand Down
16 changes: 12 additions & 4 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use winit::{
dpi::{LogicalPosition, LogicalSize, PhysicalPosition},
event::{self, DeviceEvent, Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
window::CursorGrabMode,
};

#[derive(Default)]
Expand Down Expand Up @@ -138,10 +139,17 @@ fn change_window(
window.set_cursor_icon(converters::convert_cursor_icon(icon));
}
bevy_window::WindowCommand::SetCursorLockMode { locked } => {
let window = winit_windows.get_window(id).unwrap();
window
.set_cursor_grab(locked)
.unwrap_or_else(|e| error!("Unable to un/grab cursor: {}", e));
if locked {
let window = winit_windows.get_window(id).unwrap();
window
.set_cursor_grab(CursorGrabMode::Confined)
.unwrap_or_else(|e| error!("Unable to grab cursor: {}", e));
} else {
let window = winit_windows.get_window(id).unwrap();
window
.set_cursor_grab(CursorGrabMode::None)
.unwrap_or_else(|e| error!("Unable to ungrab cursor: {}", e));
}
}
bevy_window::WindowCommand::SetCursorVisibility { visible } => {
let window = winit_windows.get_window(id).unwrap();
Expand Down
12 changes: 8 additions & 4 deletions crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy_window::{MonitorSelection, Window, WindowDescriptor, WindowId, WindowMo
use raw_window_handle::HasRawWindowHandle;
use winit::{
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize},
window::Fullscreen,
window::{CursorGrabMode, Fullscreen},
};

#[derive(Debug, Default)]
Expand Down Expand Up @@ -159,7 +159,7 @@ impl WinitWindows {
}

if window_descriptor.cursor_locked {
match winit_window.set_cursor_grab(true) {
match winit_window.set_cursor_grab(CursorGrabMode::Locked) {
Ok(_) | Err(winit::error::ExternalError::NotSupported(_)) => {}
Err(err) => Err(err).unwrap(),
}
Expand Down Expand Up @@ -241,7 +241,9 @@ pub fn get_fitting_videomode(
match abs_diff(a.size().width, width).cmp(&abs_diff(b.size().width, width)) {
Equal => {
match abs_diff(a.size().height, height).cmp(&abs_diff(b.size().height, height)) {
Equal => b.refresh_rate().cmp(&a.refresh_rate()),
Equal => b
.refresh_rate_millihertz()
.cmp(&a.refresh_rate_millihertz()),
default => default,
}
}
Expand All @@ -258,7 +260,9 @@ pub fn get_best_videomode(monitor: &winit::monitor::MonitorHandle) -> winit::mon
use std::cmp::Ordering::*;
match b.size().width.cmp(&a.size().width) {
Equal => match b.size().height.cmp(&a.size().height) {
Equal => b.refresh_rate().cmp(&a.refresh_rate()),
Equal => b
.refresh_rate_millihertz()
.cmp(&a.refresh_rate_millihertz()),
default => default,
},
default => default,
Expand Down