From 63b00fdfa039c669a38686f2feb370c4352d7922 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 28 Feb 2023 12:52:13 -0800 Subject: [PATCH 1/4] Impl --- .../macos/framework/Headers/FlutterEngine.h | 2 +- .../Headers/FlutterPluginRegistrarMacOS.h | 2 +- .../framework/Headers/FlutterViewController.h | 2 +- .../macos/framework/Source/FlutterCompositor.h | 2 +- .../macos/framework/Source/FlutterCompositor.mm | 2 +- .../framework/Source/FlutterCompositorTest.mm | 4 ++-- .../macos/framework/Source/FlutterEngine.mm | 16 ++++++++-------- .../macos/framework/Source/FlutterEngineTest.mm | 10 +++++----- .../framework/Source/FlutterEngine_Internal.h | 2 +- .../Source/FlutterPlatformNodeDelegateMacTest.mm | 2 +- .../macos/framework/Source/FlutterRenderer.h | 4 ++-- .../macos/framework/Source/FlutterRenderer.mm | 8 ++++---- .../framework/Source/FlutterViewController.mm | 6 +++--- .../Source/FlutterViewController_Internal.h | 2 +- .../Source/FlutterViewEngineProvider.mm | 2 +- .../Source/FlutterViewEngineProviderTest.mm | 2 +- .../macos/framework/Source/FlutterViewProvider.h | 4 ++-- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h b/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h index 7c7bea715893b..a7b6dd7288e12 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h @@ -26,7 +26,7 @@ * backward compatibility, single-view APIs will always operate on the view with * this ID. Also, the first view assigned to the engine will also have this ID. */ -extern const uint64_t kFlutterDefaultViewId; +extern const int64_t kFlutterDefaultViewId; @class FlutterViewController; diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h index 39fbba1b43bd3..34daed1ece877 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h @@ -47,7 +47,7 @@ FLUTTER_DARWIN_EXPORT /** * The `NSView` associated with the given view ID, if any. */ -- (nullable NSView*)viewForId:(uint64_t)viewId; +- (nullable NSView*)viewForId:(int64_t)viewId; /** * Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|. diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h index 5979131f7451b..2643399dfbc95 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h @@ -61,7 +61,7 @@ FLUTTER_DARWIN_EXPORT * If the view controller is unattached (see FlutterViewController#attached), * reading this property throws an assertion. */ -@property(nonatomic, readonly) uint64_t id; +@property(nonatomic, readonly) int64_t id; /** * The style of mouse tracking to use for the view. Defaults to diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 575742df2c8ef..2e3828016174d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -49,7 +49,7 @@ class FlutterCompositor { // Presents the FlutterLayers by updating the FlutterView specified by // `view_id` using the layer content. Sets frame_started_ to false. - bool Present(uint64_t view_id, const FlutterLayer** layers, size_t layers_count); + bool Present(int64_t view_id, const FlutterLayer** layers, size_t layers_count); private: void PresentPlatformViews(FlutterView* default_base_view, diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 96acf4bb2a189..836662785e85a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -37,7 +37,7 @@ return true; } -bool FlutterCompositor::Present(uint64_t view_id, +bool FlutterCompositor::Present(int64_t view_id, const FlutterLayer** layers, size_t layers_count) { FlutterView* view = [view_provider_ viewForId:view_id]; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm index 4005b176aaf24..8755ae3f14132 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm @@ -11,7 +11,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h" #import "flutter/testing/testing.h" -extern const uint64_t kFlutterDefaultViewId; +extern const int64_t kFlutterDefaultViewId; @interface FlutterViewMockProvider : NSObject { FlutterView* _defaultView; @@ -32,7 +32,7 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view { return self; } -- (nullable FlutterView*)viewForId:(uint64_t)viewId { +- (nullable FlutterView*)viewForId:(int64_t)viewId { if (viewId == kFlutterDefaultViewId) { return _defaultView; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 46a12265b4114..3b46742e1c558 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -20,7 +20,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h" #include "flutter/shell/platform/embedder/embedder.h" -const uint64_t kFlutterDefaultViewId = 0; +const int64_t kFlutterDefaultViewId = 0; /** * Constructs and returns a FlutterLocale struct corresponding to |locale|, which must outlive @@ -83,7 +83,7 @@ @interface FlutterEngine () */ @property(nonatomic, strong) NSMutableArray* isResponseValid; -- (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId; +- (nullable FlutterViewController*)viewControllerForId:(int64_t)viewId; /** * An internal method that adds the view controller with the given ID. @@ -91,7 +91,7 @@ - (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId; * This method assigns the controller with the ID, puts the controller into the * map, and does assertions related to the default view ID. */ -- (void)registerViewController:(FlutterViewController*)controller forId:(uint64_t)viewId; +- (void)registerViewController:(FlutterViewController*)controller forId:(int64_t)viewId; /** * An internal method that removes the view controller with the given ID. @@ -100,7 +100,7 @@ - (void)registerViewController:(FlutterViewController*)controller forId:(uint64_ * map. This is an no-op if the view ID is not associated with any view * controllers. */ -- (void)deregisterViewControllerForId:(uint64_t)viewId; +- (void)deregisterViewControllerForId:(int64_t)viewId; /** * Shuts down the engine if view requirement is not met, and headless execution @@ -190,7 +190,7 @@ - (NSView*)view { return [self viewForId:kFlutterDefaultViewId]; } -- (NSView*)viewForId:(uint64_t)viewId { +- (NSView*)viewForId:(int64_t)viewId { FlutterViewController* controller = [_flutterEngine viewControllerForId:viewId]; if (controller == nil) { return nil; @@ -463,7 +463,7 @@ - (void)loadAOTData:(NSString*)assetsDir { } } -- (void)registerViewController:(FlutterViewController*)controller forId:(uint64_t)viewId { +- (void)registerViewController:(FlutterViewController*)controller forId:(int64_t)viewId { NSAssert(controller != nil, @"The controller must not be nil."); NSAssert(![controller attached], @"The incoming view controller is already attached to an engine."); @@ -473,7 +473,7 @@ - (void)registerViewController:(FlutterViewController*)controller forId:(uint64_ [_viewControllers setObject:controller forKey:@(viewId)]; } -- (void)deregisterViewControllerForId:(uint64_t)viewId { +- (void)deregisterViewControllerForId:(int64_t)viewId { FlutterViewController* oldController = [self viewControllerForId:viewId]; if (oldController != nil) { [oldController detachFromEngine]; @@ -487,7 +487,7 @@ - (void)shutDownIfNeeded { } } -- (FlutterViewController*)viewControllerForId:(uint64_t)viewId { +- (FlutterViewController*)viewControllerForId:(int64_t)viewId { FlutterViewController* controller = [_viewControllers objectForKey:@(viewId)]; NSAssert(controller == nil || controller.id == viewId, @"The stored controller has unexpected view ID."); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm index fd5f27d1f5c34..fcf54f3e691af 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm @@ -644,7 +644,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable @autoreleasepool { // Create FVC1. viewController1 = [[FlutterViewController alloc] initWithProject:project]; - EXPECT_EQ(viewController1.id, 0ull); + EXPECT_EQ(viewController1.id, 0ll); engine = viewController1.engine; engine.viewController = nil; @@ -661,7 +661,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable engine.viewController = viewController1; EXPECT_EQ(engine.viewController, viewController1); - EXPECT_EQ(viewController1.id, 0ull); + EXPECT_EQ(viewController1.id, 0ll); } TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) { @@ -675,7 +675,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable @autoreleasepool { viewController1 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; - EXPECT_EQ(viewController1.id, 0ull); + EXPECT_EQ(viewController1.id, 0ll); EXPECT_EQ(engine.viewController, viewController1); engine.viewController = nil; @@ -683,7 +683,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; - EXPECT_EQ(viewController2.id, 0ull); + EXPECT_EQ(viewController2.id, 0ll); EXPECT_EQ(engine.viewController, viewController2); } // FVC2 is deallocated but FVC1 is retained. @@ -692,7 +692,7 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable engine.viewController = viewController1; EXPECT_EQ(engine.viewController, viewController1); - EXPECT_EQ(viewController1.id, 0ull); + EXPECT_EQ(viewController1.id, 0ll); } } // namespace flutter::testing diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h index c617363c66eb8..89a4c192beec6 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h @@ -80,7 +80,7 @@ /** * The `FlutterViewController` associated with the given view ID, if any. */ -- (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId; +- (nullable FlutterViewController*)viewControllerForId:(int64_t)viewId; /** * Informs the engine that the specified view controller's window metrics have changed. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm index 276d620da47c6..b19a666cc9459 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm @@ -192,7 +192,7 @@ // Set up embedder API mock. FlutterSemanticsAction called_action; - uint64_t called_id; + int64_t called_id; engine.embedderAPI.DispatchSemanticsAction = MOCK_ENGINE_PROC( DispatchSemanticsAction, diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h index 483a858032bc8..47e280296ae80 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h @@ -38,12 +38,12 @@ /** * Called by the engine when the given view's buffers should be swapped. */ -- (BOOL)present:(uint64_t)viewId texture:(nonnull const FlutterMetalTexture*)texture; +- (BOOL)present:(int64_t)viewId texture:(nonnull const FlutterMetalTexture*)texture; /** * Creates a Metal texture for the given view with the given size. */ -- (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size; +- (FlutterMetalTexture)createTextureForView:(int64_t)viewId size:(CGSize)size; /** * Populates the texture registry with the provided metalTexture. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm index d7d2c2fc7d6ac..fcee537f3b404 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm @@ -17,7 +17,7 @@ static FlutterMetalTexture OnGetNextDrawableForDefaultView(FlutterEngine* engine // TODO(dkwingsmt): This callback only supports single-view, therefore it only // operates on the default view. To support multi-view, we need a new callback // that also receives a view ID, or pass the ID via FlutterFrameInfo. - uint64_t viewId = kFlutterDefaultViewId; + int64_t viewId = kFlutterDefaultViewId; CGSize size = CGSizeMake(frameInfo->size.width, frameInfo->size.height); return [engine.renderer createTextureForView:viewId size:size]; } @@ -27,7 +27,7 @@ static bool OnPresentDrawableOfDefaultView(FlutterEngine* engine, // TODO(dkwingsmt): This callback only supports single-view, therefore it only // operates on the default view. To support multi-view, we need a new callback // that also receives a view ID. - uint64_t viewId = kFlutterDefaultViewId; + int64_t viewId = kFlutterDefaultViewId; return [engine.renderer present:viewId texture:texture]; } @@ -88,7 +88,7 @@ - (FlutterRendererConfig)createRendererConfig { #pragma mark - Embedder callback implementations. -- (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size { +- (FlutterMetalTexture)createTextureForView:(int64_t)viewId size:(CGSize)size { FlutterView* view = [_viewProvider viewForId:viewId]; NSAssert(view != nil, @"Can't create texture on a non-existent view 0x%llx.", viewId); if (view == nil) { @@ -98,7 +98,7 @@ - (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size { return [view.surfaceManager surfaceForSize:size].asFlutterMetalTexture; } -- (BOOL)present:(uint64_t)viewId texture:(const FlutterMetalTexture*)texture { +- (BOOL)present:(int64_t)viewId texture:(const FlutterMetalTexture*)texture { FlutterView* view = [_viewProvider viewForId:viewId]; if (view == nil) { return NO; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 994cc8f468d69..d3c4c5b0263e6 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -289,7 +289,7 @@ @implementation FlutterViewController { std::shared_ptr _bridge; - uint64_t _id; + int64_t _id; } @dynamic id; @@ -430,7 +430,7 @@ - (void)setBackgroundColor:(NSColor*)color { [_flutterView setBackgroundColor:_backgroundColor]; } -- (uint64_t)id { +- (int64_t)id { NSAssert([self attached], @"This view controller is not attched."); return _id; } @@ -459,7 +459,7 @@ - (void)notifySemanticsEnabledChanged { return _bridge; } -- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(uint64_t)viewId { +- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(int64_t)viewId { NSAssert(_engine == nil, @"Already attached to an engine %@.", _engine); _engine = engine; _id = viewId; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h index c58602f219667..22209f98e3396 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h @@ -33,7 +33,7 @@ * * This method is called by FlutterEngine. */ -- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(uint64_t)viewId; +- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(int64_t)viewId; /** * Reset the `engine` and `id` of this controller. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm index 95c3aa53e0ee5..a4915a0cb88e1 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.mm @@ -22,7 +22,7 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine { return self; } -- (nullable FlutterView*)viewForId:(uint64_t)viewId { +- (nullable FlutterView*)viewForId:(int64_t)viewId { return [_engine viewControllerForId:viewId].flutterView; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm index 86c94a70caa60..1e9dcdf11ab5d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProviderTest.mm @@ -25,7 +25,7 @@ OCMStub([mockEngine viewControllerForId:0]) .ignoringNonObjectArgs() .andDo(^(NSInvocation* invocation) { - uint64_t viewId; + int64_t viewId; [invocation getArgument:&viewId atIndex:2]; if (viewId == 0 /* kFlutterDefaultViewId */) { if (mockFlutterViewController != nil) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h b/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h index 9548b7afab1b8..e772573518650 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h @@ -4,7 +4,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" -extern const uint64_t kFlutterDefaultViewId; +extern const int64_t kFlutterDefaultViewId; /** * An interface to query FlutterView. @@ -20,6 +20,6 @@ extern const uint64_t kFlutterDefaultViewId; * * Returns nil if the ID is invalid. */ -- (nullable FlutterView*)viewForId:(uint64_t)id; +- (nullable FlutterView*)viewForId:(int64_t)id; @end From 6ec81fc9b6029ba2453f4f9849e7d6b936e2d047 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 28 Feb 2023 13:59:59 -0800 Subject: [PATCH 2/4] Format --- .../darwin/macos/framework/Source/FlutterCompositor.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 836662785e85a..890114de9d5da 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -37,9 +37,7 @@ return true; } -bool FlutterCompositor::Present(int64_t view_id, - const FlutterLayer** layers, - size_t layers_count) { +bool FlutterCompositor::Present(int64_t view_id, const FlutterLayer** layers, size_t layers_count) { FlutterView* view = [view_provider_ viewForId:view_id]; if (!view) { return false; From 4e990ab89e745b9357e0acd1d96d76c969af97d0 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Wed, 1 Mar 2023 13:30:30 -0800 Subject: [PATCH 3/4] WIP --- lib/ui/platform_dispatcher.dart | 4 ++-- lib/ui/pointer.dart | 5 +++++ lib/ui/window/pointer_data.h | 7 ++++--- .../flutter/embedding/android/AndroidTouchProcessor.java | 9 +++++++-- .../framework/Headers/FlutterPluginRegistrarMacOS.h | 5 +++++ .../darwin/macos/framework/Source/FlutterEngine.mm | 2 -- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 90112aad40f78..c289d1f8f0cc3 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -395,9 +395,8 @@ class PlatformDispatcher { // If this value changes, update the encoding code in the following files: // // * pointer_data.cc - // * pointer.dart // * AndroidTouchProcessor.java - static const int _kPointerDataFieldCount = 36; + static const int _kPointerDataFieldCount = 37; static PointerDataPacket _unpackPointerDataPacket(ByteData packet) { const int kStride = Int64List.bytesPerElement; @@ -443,6 +442,7 @@ class PlatformDispatcher { panDeltaY: packet.getFloat64(kStride * offset++, _kFakeHostEndian), scale: packet.getFloat64(kStride * offset++, _kFakeHostEndian), rotation: packet.getFloat64(kStride * offset++, _kFakeHostEndian), + viewId: packet.getInt64(kStride * offset++, _kFakeHostEndian), preferredStylusAuxiliaryAction: PointerPreferredStylusAuxiliaryAction.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)], )); assert(offset == (i + 1) * _kPointerDataFieldCount); diff --git a/lib/ui/pointer.dart b/lib/ui/pointer.dart index 4585fbcbf0a87..0414e563a7543 100644 --- a/lib/ui/pointer.dart +++ b/lib/ui/pointer.dart @@ -197,6 +197,7 @@ class PointerData { this.panDeltaY = 0.0, this.scale = 0.0, this.rotation = 0.0, + this.viewId = 0, this.preferredStylusAuxiliaryAction = PointerPreferredStylusAuxiliaryAction.ignore, }); @@ -396,6 +397,9 @@ class PointerData { /// The current angle of the pan/zoom in radians, with 0.0 as the initial angle. final double rotation; + /// The ID of the view that this event took place. + final int viewId; + /// For events with signal kind of stylusAuxiliaryAction /// /// The current preferred action for stylusAuxiliaryAction, with ignore as the default. @@ -441,6 +445,7 @@ class PointerData { 'panDeltaY: $panDeltaY, ' 'scale: $scale, ' 'rotation: $rotation, ' + 'viewId: $viewId, ' 'preferredStylusAuxiliaryAction: $preferredStylusAuxiliaryAction' ')'; } diff --git a/lib/ui/window/pointer_data.h b/lib/ui/window/pointer_data.h index 1dc159554ad74..fbd9b519b0bf6 100644 --- a/lib/ui/window/pointer_data.h +++ b/lib/ui/window/pointer_data.h @@ -9,9 +9,9 @@ namespace flutter { -// If this value changes, update the pointer data unpacking code in -// platform_dispatcher.dart. -static constexpr int kPointerDataFieldCount = 36; +// If this value changes, other places need changing too. See +// _kPointerDataFieldCount in platform_dispatcher.dart. +static constexpr int kPointerDataFieldCount = 37; static constexpr int kBytesPerField = sizeof(int64_t); // Must match the button constants in events.dart. enum PointerButtonMouse : int64_t { @@ -110,6 +110,7 @@ struct alignas(8) PointerData { double pan_delta_y; double scale; double rotation; + int64_t view_id; PreferredStylusAuxiliaryAction preferred_auxiliary_stylus_action; void Clear(); diff --git a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java index ea36686e7c8b7..3f72c98c899c0 100644 --- a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java +++ b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java @@ -94,8 +94,9 @@ public class AndroidTouchProcessor { int UNKNOWN = 4; } - // Must match the unpacking code in hooks.dart. - private static final int POINTER_DATA_FIELD_COUNT = 36; + // If this value changes, other places need changing too. See + // _kPointerDataFieldCount in platform_dispatcher.dart. + private static final int POINTER_DATA_FIELD_COUNT = 37; @VisibleForTesting static final int BYTES_PER_FIELD = 8; // This value must match the value in framework's platform_view.dart. @@ -238,6 +239,8 @@ private void addPointerForIndex( int pointerData, Matrix transformMatrix, ByteBuffer packet) { + // TODO(dkwingsmt): Get the source view ID from event data. + int viewId = 0; if (pointerChange == -1) { return; } @@ -373,6 +376,8 @@ private void addPointerForIndex( packet.putDouble(1.0); // scale packet.putDouble(0.0); // rotation + packet.putLong(viewId); // viewId + packet.putLong(PointerPreferredStylusAuxiliaryAction.IGNORE); // preferred stylus action if (isTrackpadPan && getPointerChangeForPanZoom(pointerChange) == PointerChange.PAN_ZOOM_END) { diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h index 34daed1ece877..025edd638b3c6 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h @@ -4,6 +4,8 @@ #import +#include + #import "FlutterBinaryMessenger.h" #import "FlutterChannels.h" #import "FlutterMacros.h" @@ -11,6 +13,9 @@ #import "FlutterPluginMacOS.h" #import "FlutterTexture.h" +typedef int64_t FlutterViewId; +constexpr int64_t kFlutterDefaultViewId = 0; + // TODO: Merge this file and FlutterPluginMacOS.h with the iOS FlutterPlugin.h, sharing all but // the platform-specific methods. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 3b46742e1c558..b9aea56024182 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -20,8 +20,6 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h" #include "flutter/shell/platform/embedder/embedder.h" -const int64_t kFlutterDefaultViewId = 0; - /** * Constructs and returns a FlutterLocale struct corresponding to |locale|, which must outlive * the returned struct. From bea9f46a6423c73a5c4f073ca8e8dc5a6e6f6643 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 30 Mar 2023 15:16:57 -0700 Subject: [PATCH 4/4] Fix web.PointerData --- lib/web_ui/lib/pointer.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/web_ui/lib/pointer.dart b/lib/web_ui/lib/pointer.dart index fd7981bc354a7..b20f45c2864f3 100644 --- a/lib/web_ui/lib/pointer.dart +++ b/lib/web_ui/lib/pointer.dart @@ -89,6 +89,7 @@ class PointerData { this.panDeltaY = 0.0, this.scale = 0.0, this.rotation = 0.0, + this.viewId = 0, this.preferredStylusAuxiliaryAction = PointerPreferredStylusAuxiliaryAction.ignore, }); final int embedderId; @@ -126,6 +127,7 @@ class PointerData { final double panDeltaY; final double scale; final double rotation; + final int viewId; final PointerPreferredStylusAuxiliaryAction preferredStylusAuxiliaryAction; @override @@ -166,6 +168,7 @@ class PointerData { 'panDeltaY: $panDeltaY, ' 'scale: $scale, ' 'rotation: $rotation, ' + 'viewId: $viewId, ' 'preferredStylusAuxiliaryAction: $preferredStylusAuxiliaryAction' ')'; }