mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Forward Windows scroll events to APZ when async scrolling is enabled. (bug 1086162 part 2, r=jmathies)
This commit is contained in:
parent
028b163679
commit
e05810e552
@ -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;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
**************************************************************
|
||||
**
|
||||
|
@ -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<APZCTreeManager> mAPZC;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user