Make MouseTracker.sendMouseNotifications private (#41879)
* Make sendMouseNotifications private
This commit is contained in:
@@ -131,8 +131,8 @@ class MouseTracker extends ChangeNotifier {
|
||||
/// Stops tracking an annotation, indicating that it has been removed from the
|
||||
/// layer tree.
|
||||
///
|
||||
/// If the associated layer is not removed, and receives a hit, then
|
||||
/// [sendMouseNotifications] will assert the next time it is called.
|
||||
/// An assertion error will be thrown if the associated layer is not removed
|
||||
/// and receives another mouse hit.
|
||||
void detachAnnotation(MouseTrackerAnnotation annotation) {
|
||||
final _TrackedAnnotation trackedAnnotation = _findAnnotation(annotation);
|
||||
for (int deviceId in trackedAnnotation.activeDevices) {
|
||||
@@ -155,7 +155,7 @@ class MouseTracker extends ChangeNotifier {
|
||||
if (_trackedAnnotations.isNotEmpty && !_scheduledPostFramePositionCheck) {
|
||||
_scheduledPostFramePositionCheck = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
|
||||
sendMouseNotifications(_lastMouseEvent.keys);
|
||||
_sendMouseNotifications(_lastMouseEvent.keys);
|
||||
_scheduledPostFramePositionCheck = false;
|
||||
});
|
||||
}
|
||||
@@ -171,14 +171,14 @@ class MouseTracker extends ChangeNotifier {
|
||||
// If we are adding the device again, then we're not removing it anymore.
|
||||
_pendingRemovals.remove(deviceId);
|
||||
_addMouseEvent(deviceId, event);
|
||||
sendMouseNotifications(<int>{deviceId});
|
||||
_sendMouseNotifications(<int>{deviceId});
|
||||
return;
|
||||
}
|
||||
if (event is PointerRemovedEvent) {
|
||||
_removeMouseEvent(deviceId, event);
|
||||
// If the mouse was removed, then we need to schedule one more check to
|
||||
// exit any annotations that were active.
|
||||
sendMouseNotifications(<int>{deviceId});
|
||||
_sendMouseNotifications(<int>{deviceId});
|
||||
} else {
|
||||
if (event is PointerMoveEvent || event is PointerHoverEvent || event is PointerDownEvent) {
|
||||
final PointerEvent lastEvent = _lastMouseEvent[deviceId];
|
||||
@@ -187,7 +187,7 @@ class MouseTracker extends ChangeNotifier {
|
||||
lastEvent is PointerAddedEvent || lastEvent.position != event.position) {
|
||||
// Only schedule a frame if we have our first event, or if the
|
||||
// location of the mouse has changed, and only if there are tracked annotations.
|
||||
sendMouseNotifications(<int>{deviceId});
|
||||
_sendMouseNotifications(<int>{deviceId});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,17 +212,13 @@ class MouseTracker extends ChangeNotifier {
|
||||
return _trackedAnnotations.containsKey(annotation);
|
||||
}
|
||||
|
||||
/// Tells interested objects that a mouse has entered, exited, or moved, given
|
||||
/// a callback to fetch the [MouseTrackerAnnotation] associated with a global
|
||||
/// offset.
|
||||
///
|
||||
/// This is called from a post-frame callback when the layer tree has been
|
||||
/// updated, right after rendering the frame.
|
||||
///
|
||||
/// This function is only public to allow for proper testing of the
|
||||
/// MouseTracker. Do not call in other contexts.
|
||||
@visibleForTesting
|
||||
void sendMouseNotifications(Iterable<int> deviceIds) {
|
||||
// Tells interested objects that a mouse has entered, exited, or moved, given
|
||||
// a callback to fetch the [MouseTrackerAnnotation] associated with a global
|
||||
// offset.
|
||||
//
|
||||
// This is called from a post-frame callback when the layer tree has been
|
||||
// updated, right after rendering the frame.
|
||||
void _sendMouseNotifications(Iterable<int> deviceIds) {
|
||||
if (_trackedAnnotations.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,6 @@ void main() {
|
||||
_pointerData(PointerChange.hover, const Offset(1.0, 401.0), device: 1),
|
||||
]);
|
||||
RendererBinding.instance.mouseTracker.attachAnnotation(annotation);
|
||||
RendererBinding.instance.mouseTracker.sendMouseNotifications(<int>{0});
|
||||
isInHitRegionOne = true;
|
||||
ui.window.onPointerDataPacket(packet1);
|
||||
expect(events, _equalToEventsOnCriticalFields(<PointerEvent>[
|
||||
@@ -124,11 +123,9 @@ void main() {
|
||||
// add in a second mouse simultaneously.
|
||||
clear();
|
||||
ui.window.onPointerDataPacket(packet5);
|
||||
RendererBinding.instance.mouseTracker.sendMouseNotifications(<int>{1});
|
||||
expect(events, _equalToEventsOnCriticalFields(<PointerEvent>[
|
||||
const PointerEnterEvent(position: Offset(1.0, 401.0), device: 1),
|
||||
const PointerHoverEvent(position: Offset(1.0, 401.0), device: 1),
|
||||
const PointerHoverEvent(position: Offset(1.0, 401.0), device: 1),
|
||||
]));
|
||||
});
|
||||
|
||||
@@ -142,7 +139,6 @@ void main() {
|
||||
]);
|
||||
isInHitRegionOne = true;
|
||||
RendererBinding.instance.mouseTracker.attachAnnotation(annotation);
|
||||
RendererBinding.instance.mouseTracker.sendMouseNotifications(<int>{0});
|
||||
|
||||
ui.window.onPointerDataPacket(packet1);
|
||||
|
||||
@@ -196,7 +192,6 @@ void main() {
|
||||
]);
|
||||
isInHitRegionOne = true;
|
||||
RendererBinding.instance.mouseTracker.attachAnnotation(annotation);
|
||||
RendererBinding.instance.mouseTracker.sendMouseNotifications(<int>{0});
|
||||
ui.window.onPointerDataPacket(packet1);
|
||||
ui.window.onPointerDataPacket(packet2);
|
||||
expect(events, _equalToEventsOnCriticalFields(<PointerEvent>[
|
||||
@@ -219,7 +214,6 @@ void main() {
|
||||
]);
|
||||
isInHitRegionOne = true;
|
||||
RendererBinding.instance.mouseTracker.attachAnnotation(annotation);
|
||||
RendererBinding.instance.mouseTracker.sendMouseNotifications(<int>{0});
|
||||
ui.window.onPointerDataPacket(packet1);
|
||||
ui.window.onPointerDataPacket(packet2);
|
||||
expect(events, _equalToEventsOnCriticalFields(<PointerEvent>[
|
||||
|
||||
Reference in New Issue
Block a user