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

CursorGrabMode::Confined on Linux panicks on startup #7007

Closed
vrmaurice opened this issue Dec 22, 2022 · 2 comments
Closed

CursorGrabMode::Confined on Linux panicks on startup #7007

vrmaurice opened this issue Dec 22, 2022 · 2 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Startup A crash that occurs when first attempting to run a Bevy app O-Linux Specific to the Linux desktop operating system P-Crash A sudden unexpected crash

Comments

@vrmaurice
Copy link

vrmaurice commented Dec 22, 2022

Bevy version

Bevy 9.1

Operating System

Fedora Linux Workstation 37

What you did

I tried to confine the mouse cursor using WindowDescriptor.

App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
            window: WindowDescriptor {
                title: "Test Window".to_string(),
                present_mode: bevy::window::PresentMode::AutoVsync,
                cursor_grab_mode: CursorGrabMode::Confined,
                cursor_visible: false,
                ..default()
            },
            ..default()
        }))
.run()

What went wrong

The code compiles successfully, but panicks at startup.
I get this error:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Os(OsError { line: 1333, file: "/home/maurice/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/window.rs", error: XMisc("Cursor could not be confined: confine location not viewable") })', /home/maurice/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.9.1/src/winit_windows.rs:171:38
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Additional information

This occurs both on Wayland and X11.

@vrmaurice vrmaurice added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 22, 2022
@vrmaurice vrmaurice reopened this Dec 22, 2022
@vrmaurice vrmaurice changed the title CursorGrabMode::Confined on Linux panicks and gives nasty error CursorGrabMode::Confined on Linux panicks and gives error Dec 22, 2022
@nicopap nicopap added A-Windowing Platform-agnostic interface layer to run your app in O-Linux Specific to the Linux desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Dec 22, 2022
@vrmaurice vrmaurice changed the title CursorGrabMode::Confined on Linux panicks and gives error CursorGrabMode::Confined on Linux panicks on startup Dec 22, 2022
@nicopap
Copy link
Contributor

nicopap commented Dec 22, 2022

Can reproduce on 2938792 on my archlinux.

Of course this is a bug, but here is a workaround until we get around to fix it:

Workaround

  1. Write a setup system that accepts a mut windows: ResMut<Windows>
  2. In the system, access the primary window with let primary = windows.get_primary_mut().unwrap()
  3. Set the grab mode using primary.set_cursor_grab_mode(new_grab_mode)

@nicopap nicopap added P-Crash A sudden unexpected crash C-Startup A crash that occurs when first attempting to run a Bevy app labels Dec 22, 2022
@VitalyAnkh
Copy link
Contributor

I will pick up this issue.

@bors bors bot closed this as completed in 9ff111e Jan 4, 2023
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

- Set the cursor grab mode after the window is built, fix bevyengine#7007, clean some conversion code.

## Solution

- Set the cursor grab mode after the window is built.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Set the cursor grab mode after the window is built, fix bevyengine#7007, clean some conversion code.

## Solution

- Set the cursor grab mode after the window is built.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Startup A crash that occurs when first attempting to run a Bevy app O-Linux Specific to the Linux desktop operating system P-Crash A sudden unexpected crash
Projects
None yet
3 participants