Skip to content

Commit 0be8ed3

Browse files
maxkatz6MrJul
authored andcommitted
Make mobile TryGetPlatformHandle consistent (#18483)
* Use AndroidViewControlHandle for android toplevel handle * Use UIViewControlHandle for iOS toplevel handle * Use JSObjectControlHandle for browser toplevel handle * Revert NativeControlHostImpl changes
1 parent 344bb85 commit 0be8ed3

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public TopLevelImpl(AvaloniaView avaloniaView, bool placeOnTop = false)
7878

7979
_systemNavigationManager = new AndroidSystemNavigationManagerImpl(avaloniaView.Context as IActivityNavigationService);
8080

81-
Surfaces = new object[] { _gl, _framebuffer, Handle };
81+
Surfaces = new object[] { _gl, _framebuffer, _view };
82+
Handle = new AndroidViewControlHandle(_view);
8283
}
8384

8485
public IInputRoot? InputRoot { get; private set; }
@@ -102,7 +103,7 @@ public TopLevelImpl(AvaloniaView avaloniaView, bool placeOnTop = false)
102103
internal InvalidationAwareSurfaceView InternalView => _view;
103104

104105
public double DesktopScaling => RenderScaling;
105-
public IPlatformHandle Handle => _view;
106+
public IPlatformHandle Handle { get; }
106107

107108
public IEnumerable<object> Surfaces { get; }
108109

src/Browser/Avalonia.Browser/BrowserTopLevelImpl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public BrowserTopLevelImpl(JSObject container, JSObject nativeControlHost, JSObj
7070
_surface.SizeChanged += OnSizeChanged;
7171
_surface.ScalingChanged += OnScalingChanged;
7272
Compositor = _surface.Compositor;
73+
74+
Handle = new JSObjectControlHandle(container);
7375
}
7476

7577
private void OnScalingChanged()

src/iOS/Avalonia.iOS/AvaloniaView.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ internal class TopLevelImpl : ITopLevelImpl
156156
public TopLevelImpl(AvaloniaView view)
157157
{
158158
_view = view;
159+
Handle = new UIViewControlHandle(_view);
160+
159161
_nativeControlHost = new NativeControlHostImpl(view);
160162
#if TVOS
161163
_storageProvider = null;

0 commit comments

Comments
 (0)