Bug 1354924 - Fix mousewheel multiplier prefs for external mouse devices on OS X. r=botond
The code in the OS X widget was calling ReceiveInputEvent on IAPZCTreeManager
with a ScrollWheelInput, which would bypass the multiplier code. This modifies
the widget to use a WidgetWheelEvent instead, so that it goes through the
IAPZCTreeManager multiplier handling for wheel inputs. Other platforms already
send wheel events in WidgetWheelEvent format so they don't have this problem.
MozReview-Commit-ID: 5gOOGnfD87W
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -842,18 +842,18 @@ APZCTreeManager::ReceiveInputEvent(Input
PanGestureInput& panInput = aEvent.AsPanGestureInput();
panInput.mHandledByAPZ = WillHandleInput(panInput);
if (!panInput.mHandledByAPZ) {
return result;
}
// If/when we enable support for pan inputs off-main-thread, we'll need
- // to duplicate this EventStateManager code or something. See the other
- // call to GetUserPrefsForWheelEvent in this file for why these fields
+ // to duplicate this EventStateManager code or something. See the call to
+ // GetUserPrefsForWheelEvent in IAPZCTreeManager.cpp for why these fields
// are stored separately.
MOZ_ASSERT(NS_IsMainThread());
WidgetWheelEvent wheelEvent = panInput.ToWidgetWheelEvent(nullptr);
EventStateManager::GetUserPrefsForWheelEvent(&wheelEvent,
&panInput.mUserDeltaMultiplierX,
&panInput.mUserDeltaMultiplierY);
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(panInput.mPanStartPoint,
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2837,24 +2837,25 @@ nsChildView::DispatchAPZWheelInputEvent(
}
}
WidgetWheelEvent event(true, eWheel, this);
if (mAPZC) {
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
-
- nsEventStatus result = mAPZC->ReceiveInputEvent(aEvent, &guid, &inputBlockId);
- if (result == nsEventStatus_eConsumeNoDefault) {
- return;
- }
-
- switch(aEvent.mInputType) {
+ nsEventStatus result = nsEventStatus_eIgnore;
+
+ switch (aEvent.mInputType) {
case PANGESTURE_INPUT: {
+ result = mAPZC->ReceiveInputEvent(aEvent, &guid, &inputBlockId);
+ if (result == nsEventStatus_eConsumeNoDefault) {
+ return;
+ }
+
PanGestureInput& panInput = aEvent.AsPanGestureInput();
event = panInput.ToWidgetWheelEvent(this);
if (aCanTriggerSwipe) {
SwipeInfo swipeInfo = SendMayStartSwipe(panInput);
event.mCanTriggerSwipe = swipeInfo.wantsSwipe;
if (swipeInfo.wantsSwipe) {
if (result == nsEventStatus_eIgnore) {
@@ -2878,17 +2879,26 @@ nsChildView::DispatchAPZWheelInputEvent(
}
if (mSwipeEventQueue && mSwipeEventQueue->inputBlockId == inputBlockId) {
mSwipeEventQueue->queuedEvents.AppendElement(panInput);
}
break;
}
case SCROLLWHEEL_INPUT: {
+ // For wheel events on OS X, send it to APZ using the WidgetInputEvent
+ // variant of ReceiveInputEvent, because the IAPZCTreeManager version of
+ // that function has special handling (for delta multipliers etc.) that
+ // we need to run. Using the InputData variant would bypass that and
+ // go straight to the APZCTreeManager subclass.
event = aEvent.AsScrollWheelInput().ToWidgetWheelEvent(this);
+ result = mAPZC->ReceiveInputEvent(event, &guid, &inputBlockId);
+ if (result == nsEventStatus_eConsumeNoDefault) {
+ return;
+ }
break;
};
default:
MOZ_CRASH("unsupported event type");
return;
}
if (event.mMessage == eWheel &&
(event.mDeltaX != 0 || event.mDeltaY != 0)) {