Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f8027a79
Commit
f8027a79
authored
Dec 05, 2019
by
Tong Mu
Committed by
Flutter GitHub Bot
Dec 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only schedule callback when there is mouse (#46113)
parent
fb69a393
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
mouse_tracking.dart
packages/flutter/lib/src/gestures/mouse_tracking.dart
+2
-0
mouse_tracking_test.dart
packages/flutter/test/gestures/mouse_tracking_test.dart
+23
-1
No files found.
packages/flutter/lib/src/gestures/mouse_tracking.dart
View file @
f8027a79
...
...
@@ -502,6 +502,8 @@ class MouseTracker extends ChangeNotifier {
void
schedulePostFrameCheck
()
{
assert
(
_duringBuildPhase
);
assert
(!
_duringDeviceUpdate
);
if
(!
mouseIsConnected
)
return
;
if
(!
_hasScheduledPostFrameCheck
)
{
_hasScheduledPostFrameCheck
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
duration
)
{
...
...
packages/flutter/test/gestures/mouse_tracking_test.dart
View file @
f8027a79
...
...
@@ -591,6 +591,27 @@ void main() {
]));
});
test
(
'should not schedule postframe callbacks when no mouse is connected'
,
()
{
const
MouseTrackerAnnotation
annotation
=
MouseTrackerAnnotation
();
_setUpMouseAnnotationFinder
((
Offset
position
)
sync
*
{
});
// This device only supports touching
ui
.
window
.
onPointerDataPacket
(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
PointerChange
.
add
,
const
Offset
(
0.0
,
100.0
),
kind:
PointerDeviceKind
.
touch
),
]));
expect
(
_mouseTracker
.
mouseIsConnected
,
isFalse
);
// Attaching an annotation just in case
_mouseTracker
.
attachAnnotation
(
annotation
);
expect
(
_binding
.
postFrameCallbacks
,
hasLength
(
0
));
_binding
.
scheduleMouseTrackerPostFrameCheck
();
expect
(
_binding
.
postFrameCallbacks
,
hasLength
(
0
));
_mouseTracker
.
detachAnnotation
(
annotation
);
});
test
(
'should not flip out if not all mouse events are listened to'
,
()
{
bool
isInHitRegionOne
=
true
;
bool
isInHitRegionTwo
=
false
;
...
...
@@ -782,12 +803,13 @@ ui.PointerData _pointerData(
PointerChange
change
,
Offset
logicalPosition
,
{
int
device
=
0
,
PointerDeviceKind
kind
=
PointerDeviceKind
.
mouse
,
})
{
return
ui
.
PointerData
(
change:
change
,
physicalX:
logicalPosition
.
dx
*
ui
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
ui
.
window
.
devicePixelRatio
,
kind:
PointerDeviceKind
.
mouse
,
kind:
kind
,
device:
device
,
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment