diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 6192bf44a2c0..246d1ffe535d 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -186,6 +186,9 @@ #define SM_CONVERTIBLESLATEMODE 0x2003 #endif +#include "mozilla/layers/CompositorParent.h" +#include "InputData.h" + using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::gfx; @@ -3736,10 +3739,50 @@ bool nsWindow::DispatchKeyboardEvent(WidgetGUIEvent* event) return ConvertStatus(status); } -bool nsWindow::DispatchScrollEvent(WidgetGUIEvent* event) +nsEventStatus nsWindow::MaybeDispatchAsyncWheelEvent(WidgetGUIEvent* aEvent) { + if (aEvent->mClass != eWheelEventClass) { + return nsEventStatus_eIgnore; + } + + WidgetWheelEvent* event = aEvent->AsWheelEvent(); + + // Otherwise, scroll-zoom won't work. + if (event->IsControl()) { + return nsEventStatus_eIgnore; + } + + + // Other scrolling modes aren't supported yet. + if (event->deltaMode != nsIDOMWheelEvent::DOM_DELTA_LINE) { + return nsEventStatus_eIgnore; + } + + ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; + if (Preferences::GetBool("general.smoothScroll")) + scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; + + ScreenPoint origin(event->refPoint.x, event->refPoint.y); + ScrollWheelInput input(event->time, event->timeStamp, 0, + scrollMode, + ScrollWheelInput::SCROLLDELTA_LINE, + origin, + event->lineOrPageDeltaX, + event->lineOrPageDeltaY); + + ScrollableLayerGuid ignoreGuid; + return mAPZC->ReceiveInputEvent(input, &ignoreGuid, nullptr); +} + +bool nsWindow::DispatchScrollEvent(WidgetGUIEvent* aEvent) +{ + if (mAPZC) { + if (MaybeDispatchAsyncWheelEvent(aEvent) == nsEventStatus_eConsumeNoDefault) + return true; + } + nsEventStatus status; - DispatchEvent(event, status); + DispatchEvent(aEvent, status); return ConvertStatus(status); } @@ -7672,6 +7715,19 @@ void nsWindow::PickerClosed() } } +CompositorParent* nsWindow::NewCompositorParent(int aSurfaceWidth, + int aSurfaceHeight) +{ + CompositorParent *compositor = new CompositorParent(this, false, aSurfaceWidth, aSurfaceHeight); + + if (gfxPrefs::AsyncPanZoomEnabled()) { + mAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId()); + APZCTreeManager::SetDPI(GetDPI()); + } + + return compositor; +} + /************************************************************** ************************************************************** ** diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 872ab8828254..3d95f49c0c34 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -40,10 +40,9 @@ #endif #include "nsUXThemeData.h" - #include "nsIDOMMouseEvent.h" - #include "nsIIdleServiceInternal.h" +#include "mozilla/layers/APZCTreeManager.h" /** * Forward class definitions @@ -75,6 +74,8 @@ class nsWindow : public nsWindowBase typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview; typedef mozilla::widget::NativeKey NativeKey; typedef mozilla::widget::MSGResult MSGResult; + typedef mozilla::layers::APZCTreeManager APZCTreeManager; + public: nsWindow(); @@ -90,6 +91,7 @@ public: virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) MOZ_OVERRIDE; virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) MOZ_OVERRIDE; virtual bool IsTopLevelWidget() MOZ_OVERRIDE { return mIsTopWidgetWindow; } + virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) MOZ_OVERRIDE; // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, @@ -390,6 +392,8 @@ protected: void OnWindowPosChanging(LPWINDOWPOS& info); void OnSysColorChanged(); + nsEventStatus MaybeDispatchAsyncWheelEvent(mozilla::WidgetGUIEvent* aEvent); + /** * Function that registers when the user has been active (used for detecting * when the user is idle). @@ -591,6 +595,8 @@ protected: static bool sNeedsToInitMouseWheelSettings; static void InitMouseWheelScrollData(); + + nsRefPtr mAPZC; }; /**