From 4e72191cd13164e3d2f4d1cc4af3c4e227f02a1a Mon Sep 17 00:00:00 2001 From: bufffun Date: Tue, 4 Jun 2024 01:36:00 +0800 Subject: [PATCH 1/2] [macOS] Fix FlutterView cursor hit testing. --- shell/platform/darwin/macos/framework/Source/FlutterView.mm | 3 ++- .../platform/darwin/macos/framework/Source/FlutterViewTest.mm | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index 1eaf0d096449b..d879cd69ae870 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -107,7 +107,8 @@ - (void)didUpdateMouseCursor:(NSCursor*)cursor { // and will not restore it back. - (void)cursorUpdate:(NSEvent*)event { // Make sure to not override cursor when over a platform view. - NSView* hitTestView = [self hitTest:[self convertPoint:event.locationInWindow fromView:nil]]; + NSPoint mouseLoc = [[self superview] convertPoint:event.locationInWindow fromView:nil]; + NSView* hitTestView = [self hitTest:mouseLoc]; if (hitTestView != self) { return; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm index cc675171d8130..3c84116188392 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm @@ -110,7 +110,7 @@ - (void)set { EXPECT_TRUE(hitTestCalled); // The hit test coordinate should be in the window coordinate system. - EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 500))); + EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100))); EXPECT_TRUE(cursor.setCalled); } @@ -155,6 +155,6 @@ - (void)set { EXPECT_TRUE(hitTestCalled); // The hit test coordinate should be in the window coordinate system. - EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 500))); + EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100))); EXPECT_FALSE(cursor.setCalled); } From 2923e52c1cd51eedfa4ed3f4944c8240065b9465 Mon Sep 17 00:00:00 2001 From: bufffun Date: Tue, 4 Jun 2024 08:52:43 +0800 Subject: [PATCH 2/2] rename variable --- shell/platform/darwin/macos/framework/Source/FlutterView.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index d879cd69ae870..21a1115e73d73 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -107,8 +107,8 @@ - (void)didUpdateMouseCursor:(NSCursor*)cursor { // and will not restore it back. - (void)cursorUpdate:(NSEvent*)event { // Make sure to not override cursor when over a platform view. - NSPoint mouseLoc = [[self superview] convertPoint:event.locationInWindow fromView:nil]; - NSView* hitTestView = [self hitTest:mouseLoc]; + NSPoint mouseLocation = [[self superview] convertPoint:event.locationInWindow fromView:nil]; + NSView* hitTestView = [self hitTest:mouseLocation]; if (hitTestView != self) { return; }