Skip to content

Transform Gizmo does not work on MacOS with default TransformGizmoSettings (due to CursorGrabMode Logic) #24476

@kfc35

Description

@kfc35

Bevy version and features

On main 5dc6e46

[Optional] Relevant system information

MacOS 26.5
Using a Trackpad
AdapterInfo { name: "Apple M4", vendor: 0, device: 0, device_type: IntegratedGpu, device_pci_bus_id: "", driver: "", driver_info: "", backend: Metal, subgroup_min_size: 4, subgroup_max_size: 64, transient_saves_memory: true }

What you did

I tried to run the basic transform gizmo example without modifications and tried interacting with the transform gizmo

What went wrong

The mouse locks in place and I’m unable to move the cursor in order to scale/translate/rotate.

This is because, when using the Transform Gizmo, the cursor grab mode is set to Confined, which is unsupported on MacOS:
https://github.com/bevyengine/bevy/blob/main/crates/bevy_window/src/window.rs#L763-L772

The documentation further elucidates what happens in this case:

Since macOS and X11 don't have full [CursorGrabMode] support, we first try to set the grab mode that was asked for. If it doesn't work then use the alternate grab mode.

I was able to fix this bug by changing the base logic here of setting the cursor grab to None instead of Locked when Confined is not available:
https://github.com/bevyengine/bevy/blob/main/crates/bevy_winit/src/winit_windows.rs#L426-L428

I can also fix this by changing the “confine_cursor” field to false in TransformGizmoSettings

/// Whether to confine the cursor during drag.
pub confine_cursor: bool,

Since this caused a 15 minute distraction from trying to debug something with Transform Gizmos, I open this issue to question whether the bevy_winit fallback logic should be changed, or whether confine_cursor should maybe be false as a Default instead.

If no logic should be changed, at the very least, I think TransformGizmo should have documentation saying that confine_cursor should be set to false for MacOS due to it being unsupported there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-EditorGraphical tools to make Bevy gamesA-GizmosVisual editor and debug gizmosC-BugAn unexpected or incorrect behaviorC-DocsAn addition or correction to our documentationD-TrivialNice and easy! A great choice to get started with BevyO-MacOSSpecific to the MacOS (Apple) desktop operating systemS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions