|
|
|
@ -19,8 +19,10 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
internal class MainWindow : Window, IStyleHost |
|
|
|
{ |
|
|
|
private readonly IDisposable? _keySubscription; |
|
|
|
private readonly IDisposable? _pointerSubscription; |
|
|
|
private readonly Dictionary<Popup, IDisposable> _frozenPopupStates; |
|
|
|
private AvaloniaObject? _root; |
|
|
|
private PixelPoint _lastPointerPosition; |
|
|
|
|
|
|
|
public MainWindow() |
|
|
|
{ |
|
|
|
@ -30,6 +32,10 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
.OfType<RawKeyEventArgs>() |
|
|
|
.Where(x => x.Type == RawKeyEventType.KeyDown) |
|
|
|
.Subscribe(RawKeyDown); |
|
|
|
_pointerSubscription = InputManager.Instance?.Process |
|
|
|
.OfType<RawPointerEventArgs>() |
|
|
|
.Subscribe(x => _lastPointerPosition = x.Root.PointToScreen(x.Position)); |
|
|
|
|
|
|
|
|
|
|
|
_frozenPopupStates = new Dictionary<Popup, IDisposable>(); |
|
|
|
|
|
|
|
@ -84,6 +90,7 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
{ |
|
|
|
base.OnClosed(e); |
|
|
|
_keySubscription?.Dispose(); |
|
|
|
_pointerSubscription?.Dispose(); |
|
|
|
|
|
|
|
foreach (var state in _frozenPopupStates) |
|
|
|
{ |
|
|
|
@ -108,9 +115,7 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
|
|
|
|
private IControl? GetHoveredControl(TopLevel topLevel) |
|
|
|
{ |
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
var point = (topLevel as IInputRoot)?.MouseDevice?.GetPosition(topLevel) ?? default; |
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
var point = topLevel.PointToClient(_lastPointerPosition); |
|
|
|
|
|
|
|
return (IControl?)topLevel.GetVisualsAt(point, x => |
|
|
|
{ |
|
|
|
|