Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions flutter_inappwebview_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 0.7.0-beta.3

- Fixed reversed horizontal scrolling: two-finger trackpad pans and mouse
tilt-wheel scrolls moved the content in the opposite direction, because
`WM_MOUSEHWHEEL`'s sign convention is inverted relative to `WM_MOUSEWHEEL`.
- Fixed WebView2 input windows intercepting desktop clicks while the Flutter
host window is minimized, including WebViews created or resumed during
minimization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class _CustomPlatformViewState extends State<CustomPlatformView>
_controller._setCursorPos(signal.localPosition);
_stopFling();
_sendScrollDelta(
-signal.scrollDelta.dx,
signal.scrollDelta.dx,
-signal.scrollDelta.dy,
);
} else if (signal is PointerScrollInertiaCancelEvent) {
Expand Down Expand Up @@ -728,7 +728,8 @@ class _CustomPlatformViewState extends State<CustomPlatformView>
);
}

/// Forwards scroll deltas immediately, preserving fractional remainders.
/// Forwards raw WM wheel data immediately, preserving fractional
/// remainders. WM sign asymmetry: positive dy = up, positive dx = right.
void _sendScrollDelta(double dx, double dy) {
_scrollRemainderX += dx;
_scrollRemainderY += dy;
Expand All @@ -744,7 +745,9 @@ class _CustomPlatformViewState extends State<CustomPlatformView>

void _sendTrackpadScrollDelta(double dx, double dy) {
final delta = _dominantAxis(Offset(dx, dy));
_sendScrollDelta(delta.dx, delta.dy);
// Content follows the fingers: fingers right = scroll left = negative
// hwheel (WM_MOUSEHWHEEL positive means right, unlike the vertical axis).
_sendScrollDelta(-delta.dx, delta.dy);
}

/// Starts synthetic inertia after a fast lifted pan.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,31 @@ void main() {
await tester.pump();

// 0.5px × 1.2 × 1.5 = 0.9 units per update: whole units flush on the
// 2nd and 3rd updates.
// 2nd and 3rd updates. Fingers left → positive hwheel (scroll right is
// negative in WM terms only for the vertical axis).
expect(scrollDeltaCalls(), [
[-1.0, 0.0],
[-1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
]);
});

testWidgets('horizontal pan follows the fingers (hwheel sign is inverted '
'relative to the vertical axis)', (tester) async {
final center = await pumpView(tester);

final pointer = TestPointer(1, PointerDeviceKind.trackpad);
await tester.sendEventToBinding(pointer.panZoomStart(center));
// Fingers move right 10px: content must follow them, i.e. scroll left,
// which is a NEGATIVE WM_MOUSEHWHEEL delta (positive hwheel = right).
await tester.sendEventToBinding(
pointer.panZoomUpdate(center, pan: const Offset(10, 0)),
);
await tester.sendEventToBinding(pointer.panZoomEnd());
await tester.pump();

// 10px × 1.2 × 1.5 = 18 units, negated for the horizontal axis.
expect(scrollDeltaCalls(), [
[-18.0, 0.0],
]);
});

Expand All @@ -246,7 +267,7 @@ void main() {
await tester.pump();

expect(scrollDeltaCalls(), [
[-18.0, 0.0],
[18.0, 0.0],
[0.0, -18.0],
]);
});
Expand Down Expand Up @@ -435,6 +456,27 @@ void main() {
]);
});

testWidgets('horizontal wheel deltas are forwarded unnegated '
'(WM_MOUSEHWHEEL positive = right, unlike the vertical axis)', (
tester,
) async {
final center = await pumpView(tester);

final pointer = TestPointer(1, PointerDeviceKind.mouse);
await tester.sendEventToBinding(pointer.hover(center));
// The engine maps WM_MOUSEHWHEEL without negation, so reproducing the
// original native delta means forwarding dx as-is.
await tester.sendEventToBinding(pointer.scroll(const Offset(120, 0)));
await tester.pump();
await tester.sendEventToBinding(pointer.scroll(const Offset(-120, 0)));
await tester.pump();

expect(scrollDeltaCalls(), [
[120.0, 0.0],
[-120.0, 0.0],
]);
});

testWidgets('wheel deltas are still forwarded negated', (tester) async {
final center = await pumpView(tester);

Expand Down
Loading