Tie accesskit root nodes to winit's WindowId instead of window entity #12799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Explanation
In order for accesskit to connect to a window, an
Adapter
is required. Adapters can only be created at the moment awinit
window is initialized. Moreover, Adapters internally track aNodeId
tied to a specific window. This means theNodeId
in window adapters must be defined when windows are initialized.Currently window adapter
NodeIds
are defined from the Bevy entities that are used to track each window. The entity bits are essentially used as a proxy identifier for the underlyingwinit
window. This works just fine when there is only one Bevy world that uses a specificwinit
window. However, bevy_worldswap is a new, experimental, crate that allows you to swap the world that renders at runtime.When swapping worlds, the new foreground world (i.e. the world that will render) needs to be hooked up to existing windows. This means moving window adapters between worlds. Transferring adapters is easy enough, but the problem comes when accessibility updates in the
update_accessibility_nodes
system. New accessibility node trees are attached to the currentPrimaryWindow
via the Bevy entity id. But since we swapped to a different world, windows now live on different entities, so accessibility will not work. This is a consequence of using proxy ids for window adapters instead of directly tying adapters to windows.Solution
WindowId
for accesskit root nodes instead of the Bevy entity that tracks a window.