-
Notifications
You must be signed in to change notification settings - Fork 901
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
Crashes when RUST_LOG=info with env_logger, and window.set_grub_cursor(true) is called on Linux #2080
Comments
Grabbing the cursor requires the window to be mapped. Mapping is performed by the window manager asynchronously. |
I tried grabbing the cursor in The most awful naive hack you can imagine works, but ... there has got to be a better way! let mut grabbed_cursor = false;
let start = Instant::now();
event_loop.run(move |event, _, control_flow| match event {
Event::NewEvents(StartCause::Init) => {
println!("StartCause::Init received in {:?}", Instant::now().duration_since(start));
}
Event::MainEventsCleared => {
if !grabbed_cursor && window.set_cursor_grab(true).is_ok() {
grabbed_cursor = true;
println!("Grabbed cursor in {:?}", Instant::now().duration_since(start));
}
}
// ...
}); Example output:
|
I believe there is no way to do this at the moment. |
Grabbing the cursor upon application startup without any user interaction sounds a bit iffy to me in general (ie. I wouldn't want an application to do that). If I'm reading the protocol spec correctly, then you can't grab the pointer until the cursor enters the region you're trying to confine the cursor to. I'd recommend grabbing the cursor in response to |
I agree in general. The reason I started looking into this is that the error was mentioned in the Rust discord, and I got curious. It seems like this should really only be a concern for prototyping. A real game is expected to have a main menu and stuff that the user will interact with before the cursor is captured. |
This code, when run with
RUST_LOG=info
environment variable on Debian 11 crashes. It doesn't crash when ran withRUST_LOG=warn
.message:
winit's version is 0.26.0 and env_logger's version is 0.9.0.
The text was updated successfully, but these errors were encountered: