|
|
@ -15,6 +15,7 @@ using Avalonia.Metadata; |
|
|
using Avalonia.Platform; |
|
|
using Avalonia.Platform; |
|
|
using Avalonia.VisualTree; |
|
|
using Avalonia.VisualTree; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Media; |
|
|
|
|
|
using Avalonia.Interactivity; |
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Primitives |
|
|
namespace Avalonia.Controls.Primitives |
|
|
{ |
|
|
{ |
|
|
@ -495,13 +496,13 @@ namespace Avalonia.Controls.Primitives |
|
|
SubscribeToEventHandler<Control, EventHandler<VisualTreeAttachmentEventArgs>>(placementTarget, TargetDetached, |
|
|
SubscribeToEventHandler<Control, EventHandler<VisualTreeAttachmentEventArgs>>(placementTarget, TargetDetached, |
|
|
(x, handler) => x.DetachedFromVisualTree += handler, |
|
|
(x, handler) => x.DetachedFromVisualTree += handler, |
|
|
(x, handler) => x.DetachedFromVisualTree -= handler).DisposeWith(handlerCleanup); |
|
|
(x, handler) => x.DetachedFromVisualTree -= handler).DisposeWith(handlerCleanup); |
|
|
|
|
|
|
|
|
if (topLevel is Window window && window.PlatformImpl != null) |
|
|
if (topLevel is Window window && window.PlatformImpl != null) |
|
|
{ |
|
|
{ |
|
|
SubscribeToEventHandler<Window, EventHandler>(window, WindowDeactivated, |
|
|
SubscribeToEventHandler<Window, EventHandler>(window, WindowDeactivated, |
|
|
(x, handler) => x.Deactivated += handler, |
|
|
(x, handler) => x.Deactivated += handler, |
|
|
(x, handler) => x.Deactivated -= handler).DisposeWith(handlerCleanup); |
|
|
(x, handler) => x.Deactivated -= handler).DisposeWith(handlerCleanup); |
|
|
|
|
|
|
|
|
SubscribeToEventHandler<IWindowImpl, Action>(window.PlatformImpl, WindowLostFocus, |
|
|
SubscribeToEventHandler<IWindowImpl, Action>(window.PlatformImpl, WindowLostFocus, |
|
|
(x, handler) => x.LostFocus += handler, |
|
|
(x, handler) => x.LostFocus += handler, |
|
|
(x, handler) => x.LostFocus -= handler).DisposeWith(handlerCleanup); |
|
|
(x, handler) => x.LostFocus -= handler).DisposeWith(handlerCleanup); |
|
|
@ -535,6 +536,12 @@ namespace Avalonia.Controls.Primitives |
|
|
(x, handler) => x.Closed -= handler).DisposeWith(handlerCleanup); |
|
|
(x, handler) => x.Closed -= handler).DisposeWith(handlerCleanup); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else if (topLevel is { } tl && tl.PlatformImpl is ITopLevelImpl pimpl) |
|
|
|
|
|
{ |
|
|
|
|
|
SubscribeToEventHandler<ITopLevelImpl, Action>(pimpl, TopLevelLostPlatformFocus, |
|
|
|
|
|
(x, handler) => x.LostFocus += handler, |
|
|
|
|
|
(x, handler) => x.LostFocus -= handler).DisposeWith(handlerCleanup); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
InputManager.Instance?.Process.Subscribe(ListenForNonClientClick).DisposeWith(handlerCleanup); |
|
|
InputManager.Instance?.Process.Subscribe(ListenForNonClientClick).DisposeWith(handlerCleanup); |
|
|
|
|
|
|
|
|
@ -988,6 +995,14 @@ namespace Avalonia.Controls.Primitives |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void TopLevelLostPlatformFocus() |
|
|
|
|
|
{ |
|
|
|
|
|
if (IsLightDismissEnabled) |
|
|
|
|
|
{ |
|
|
|
|
|
Close(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void PlacementTargetTransformChanged(Visual v, Matrix? matrix) |
|
|
private void PlacementTargetTransformChanged(Visual v, Matrix? matrix) |
|
|
{ |
|
|
{ |
|
|
if (_openState is not null) |
|
|
if (_openState is not null) |
|
|
|