3232 @" NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification" ;
3333static NSString * const EnhancedUserInterfaceKey = @" AXEnhancedUserInterface" ;
3434
35+ // Use different device ID for mouse and pan/zoom events, since we can't differentiate the actual
36+ // device (mouse v.s. trackpad)
37+ static constexpr int32_t kMousePointerDeviceId = 0 ;
38+ static constexpr int32_t kPointerPanZoomDeviceId = 1 ;
39+
3540/* *
3641 * State tracking for mouse events, to adapt between the events coming from the system and the
3742 * events that the embedding API expects.
@@ -612,15 +617,18 @@ - (void)dispatchMouseEvent:(NSEvent*)event phase:(FlutterPointerPhase)phase {
612617 .timestamp = static_cast <size_t >(event.timestamp * USEC_PER_SEC),
613618 .x = locationInBackingCoordinates.x ,
614619 .y = -locationInBackingCoordinates.y , // convertPointToBacking makes this negative.
620+ .device = kMousePointerDeviceId ,
615621 .device_kind = kFlutterPointerDeviceKindMouse ,
616622 // If a click triggered a synthesized kAdd, don't pass the buttons in that event.
617623 .buttons = phase == kAdd ? 0 : _mouseState.buttons ,
618624 };
619625
620626 if (phase == kPanZoomStart ) {
621627 flutterEvent.device_kind = kFlutterPointerDeviceKindTouch ;
628+ flutterEvent.device = kPointerPanZoomDeviceId ;
622629 } else if (phase == kPanZoomUpdate ) {
623630 flutterEvent.device_kind = kFlutterPointerDeviceKindTouch ;
631+ flutterEvent.device = kPointerPanZoomDeviceId ;
624632 if (event.type == NSEventTypeScrollWheel) {
625633 _mouseState.deltaX += event.scrollingDeltaX * self.flutterView .layer .contentsScale ;
626634 _mouseState.deltaY += event.scrollingDeltaY * self.flutterView .layer .contentsScale ;
@@ -636,6 +644,7 @@ - (void)dispatchMouseEvent:(NSEvent*)event phase:(FlutterPointerPhase)phase {
636644 flutterEvent.rotation = _mouseState.rotation ;
637645 } else if (phase == kPanZoomEnd ) {
638646 flutterEvent.device_kind = kFlutterPointerDeviceKindTouch ;
647+ flutterEvent.device = kPointerPanZoomDeviceId ;
639648 _mouseState.GestureReset ();
640649 } else if (event.type == NSEventTypeScrollWheel) {
641650 flutterEvent.signal_kind = kFlutterPointerSignalKindScroll ;
0 commit comments