More changes for non-toplevel visual tree roots.#20732
Conversation
…ee. This is needed for our future changes.
There was a problem hiding this comment.
Pull request overview
This PR introduces significant architectural changes to the Avalonia visual tree structure by adding TopLevelHost as the actual visual root instead of TopLevel. This is preparatory work for enabling Client-Side Decorations (CSDs) for Wayland and making the Window class accessible on mobile/wasm/embedded platforms.
Changes:
- Introduces
TopLevelHostas a stub visual root wrappingTopLevel, establishing thatTopLevelis no longer the visual tree root - Makes layer-related classes and interfaces internal (
VisualLayerManager,AdornerLayer,OverlayLayer,LightDismissOverlayLayer,IPopupHost,IPopupHostProvider,IHostedVisualTreeRoot) - Adds
FocusRootproperty toIInputRootto separate focus management from visual tree root concepts
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Avalonia.Controls/TopLevelHost.cs | New internal stub class that serves as the visual tree root, containing TopLevel as a child |
| src/Avalonia.Controls/TopLevel.cs | Creates TopLevelHost and updates PresentationSource initialization with separate visual and focus roots |
| src/Avalonia.Controls/PresentationSource/PresentationSource.cs | Accepts separate rootVisual and defaultFocusVisual parameters to support the new architecture |
| src/Avalonia.Controls/PresentationSource/PresentationSource.Input.cs | Adds FocusRoot property to support focus management |
| src/Avalonia.Base/Input/IInputRoot.cs | Adds FocusRoot property with documentation explaining it as a temporary hack for default focus |
| src/Avalonia.Base/Input/KeyboardDevice.cs | Uses FocusRoot instead of RootElement for keyboard event routing |
| src/Avalonia.Base/Input/FocusManager.cs | Updates focus root resolution to use PresentationSource.InputRoot.FocusRoot |
| src/Avalonia.Controls/ToolTipService.cs | Updates tooltip event root comparison to work with new visual tree structure |
| src/Avalonia.Controls/Primitives/* | Makes layer classes and properties internal (VisualLayerManager, AdornerLayer, OverlayLayer, etc.) |
| src/Avalonia.X11/X11Window.cs | Updates storage provider initialization to use FocusRoot instead of RootElement |
| tests/* | Updates tests to expect TopLevelHost in visual tree, fixes test expectations, adds FocusRoot to test implementations |
| api/Avalonia.nupkg.xml | Adds API compatibility suppressions for breaking changes (internal visibility changes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
Main changes are from AvaloniaUI/Avalonia#20732 AvaloniaUI/Avalonia#20767 Where a number of previously public things were made internal.
|
Looks like this may have created a cycle in the new dev tools; haven't create an issue as I'm not sure where best to report this sort of thing for the new tooling (does it come under https://github.com/AvaloniaUI/Accelerate/issues ?). Screenshot is from the sandbox on master
|

This PR:
VisualLayerManagerand relevant layers to beinternal, since we are planning to migrate those outside ofTopLevel's subtree laterTopLevel. To get aTopLevelone needs to callTopLevel.GetTopLevel(visual).This is a part of our work for unlocking CSDs for Wayland and making Window class accessible on mobile/wasm/embedded platforms.