From ced49062ec7b16a1d0eb80aa46a529ce9097b1c0 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 2 Oct 2024 20:52:31 +0500 Subject: [PATCH] Don't apply our weird window positioning hacks for clicks on traffic lights This hack fixes the minimize problem with macOS 15.0 --- native/Avalonia.Native/src/OSX/AvnWindow.mm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/native/Avalonia.Native/src/OSX/AvnWindow.mm b/native/Avalonia.Native/src/OSX/AvnWindow.mm index e6d451d0bf4..6f5e33a1c8c 100644 --- a/native/Avalonia.Native/src/OSX/AvnWindow.mm +++ b/native/Avalonia.Native/src/OSX/AvnWindow.mm @@ -452,6 +452,16 @@ - (AvnPoint) translateLocalPoint:(AvnPoint)pt return pt; } +- (NSView*) findRootView:(NSView*)view +{ + while (true) { + auto parent = [view superview]; + if(parent == nil) + return view; + view = parent; + } +} + - (void)sendEvent:(NSEvent *_Nonnull)event { [super sendEvent:event]; @@ -467,7 +477,15 @@ - (void)sendEvent:(NSEvent *_Nonnull)event AvnView* view = parent->View; NSPoint windowPoint = [event locationInWindow]; NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil]; - + + auto targetView = [[self findRootView:view] hitTest: windowPoint]; + if(targetView) + { + auto targetViewClass = [targetView className]; + if([targetViewClass containsString: @"_NSThemeWidget"]) + return; + } + if (!NSPointInRect(viewPoint, view.bounds)) { auto avnPoint = ToAvnPoint(windowPoint);