mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
do not set cursor grab on window creation if not asked for (#6381)
# Objective - Bevy main crashs on Safari mobile - On Safari mobile, calling winit_window.set_cursor_grab(true) fails as the API is not implemented (as there is no cursor on Safari mobile, the api doesn't make sense there). I don't know about other mobile browsers ## Solution - Do not call the api to release cursor grab on window creation, as the cursor is not grabbed anyway at this point - This is #3617 which was lost in #6218
This commit is contained in:
parent
bf6c457553
commit
ca82fa883b
1 changed files with 10 additions and 6 deletions
|
@ -2,7 +2,8 @@ use crate::converters::convert_cursor_grab_mode;
|
|||
use bevy_math::{DVec2, IVec2};
|
||||
use bevy_utils::HashMap;
|
||||
use bevy_window::{
|
||||
MonitorSelection, RawHandleWrapper, Window, WindowDescriptor, WindowId, WindowMode,
|
||||
CursorGrabMode, MonitorSelection, RawHandleWrapper, Window, WindowDescriptor, WindowId,
|
||||
WindowMode,
|
||||
};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
use winit::{
|
||||
|
@ -161,11 +162,14 @@ impl WinitWindows {
|
|||
}
|
||||
}
|
||||
|
||||
match winit_window
|
||||
.set_cursor_grab(convert_cursor_grab_mode(window_descriptor.cursor_grab_mode))
|
||||
{
|
||||
Ok(_) | Err(winit::error::ExternalError::NotSupported(_)) => {}
|
||||
Err(err) => Err(err).unwrap(),
|
||||
// Do not set the grab mode on window creation if it's none, this can fail on mobile
|
||||
if window_descriptor.cursor_grab_mode != CursorGrabMode::None {
|
||||
match winit_window
|
||||
.set_cursor_grab(convert_cursor_grab_mode(window_descriptor.cursor_grab_mode))
|
||||
{
|
||||
Ok(_) | Err(winit::error::ExternalError::NotSupported(_)) => {}
|
||||
Err(err) => Err(err).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
winit_window.set_cursor_visible(window_descriptor.cursor_visible);
|
||||
|
|
Loading…
Reference in a new issue