Bug 782729 - Ensure pointer lock code always passes screen coords to SynthesizeNativeMouseMove. r=smaug

This commit is contained in:
Chris Pearce 2012-09-25 11:43:27 +12:00
parent 1540f7ce6f
commit 1a1fe842d7
2 changed files with 9 additions and 4 deletions

View File

@ -4089,7 +4089,8 @@ nsEventStateManager::NotifyMouseOver(nsGUIEvent* aEvent, nsIContent* aContent)
// Returns the center point of the window's inner content area.
// This is in widget coordinates, i.e. relative to the widget's top
// left corner, not in screen coordinates.
// left corner, not in screen coordinates, the same units that
// nsDOMUIEvent::refPoint is in.
static nsIntPoint
GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
nsIWidget* aWidget,
@ -4142,7 +4143,8 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
// This mouse move doesn't finish at the center of the widget,
// dispatch a synthetic mouse move to return the mouse back to
// the center.
aEvent->widget->SynthesizeNativeMouseMove(center);
aEvent->widget->SynthesizeNativeMouseMove(
center + aEvent->widget->WidgetToScreenOffset());
}
} else {
aEvent->lastRefPoint = sLastRefPoint;
@ -4214,7 +4216,8 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
sLastRefPoint = GetWindowInnerRectCenter(aElement->OwnerDoc()->GetWindow(),
aWidget,
mPresContext);
aWidget->SynthesizeNativeMouseMove(sLastRefPoint);
aWidget->SynthesizeNativeMouseMove(
sLastRefPoint + aWidget->WidgetToScreenOffset());
// Retarget all events to this element via capture.
nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK);
@ -4229,7 +4232,8 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
// pre-pointerlock position, so that the synthetic mouse event reports
// no movement.
sLastRefPoint = mPreLockPoint;
aWidget->SynthesizeNativeMouseMove(mPreLockPoint);
aWidget->SynthesizeNativeMouseMove(
mPreLockPoint + aWidget->WidgetToScreenOffset());
// Don't retarget events to this element any more.
nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK);

View File

@ -1357,6 +1357,7 @@ class nsIWidget : public nsISupports {
/**
* A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message.
* aPoint is location in device pixels to which the mouse pointer moves to.
*/
virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0;