fix scrollwheel issues. make sure we reset origin before calling GlobalToLocal() and xlate local mouse coord into widget-relative coords for gecko. r=bryner/sr=sfraser/a=shaver. bug#125570

This commit is contained in:
pinkerton%netscape.com 2002-02-21 23:09:13 +00:00
Родитель 903c5347ec
Коммит 99c427f69f
2 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -148,6 +148,12 @@ HandleScrollEvent ( EventMouseWheelAxis inAxis, PRBool inByLine, PRInt32 inDelta
if ( !inByLine )
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
// convert window-relative (local) mouse coordinates to widget-relative
// coords for Gecko.
nsPoint widgetOrigin(0, 0);
inWidget->ConvertToDeviceCoordinates(widgetOrigin.x, widgetOrigin.y);
nsPoint mouseLocRelativeToWidget(inMouseLoc.h - widgetOrigin.x, inMouseLoc.v - widgetOrigin.y);
scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT;
scrollEvent.isShift = PR_FALSE;
scrollEvent.isControl = PR_FALSE;
@ -155,8 +161,8 @@ HandleScrollEvent ( EventMouseWheelAxis inAxis, PRBool inByLine, PRInt32 inDelta
scrollEvent.isAlt = PR_FALSE;
scrollEvent.message = NS_MOUSE_SCROLL;
scrollEvent.delta = inDelta;
scrollEvent.point.x = inMouseLoc.h;
scrollEvent.point.y = inMouseLoc.v;
scrollEvent.point.x = mouseLocRelativeToWidget.x;
scrollEvent.point.y = mouseLocRelativeToWidget.y;
scrollEvent.time = PR_IntervalNow();
scrollEvent.widget = inWidget;
scrollEvent.nativeMsg = nsnull;

Просмотреть файл

@ -644,8 +644,9 @@ nsMacWindow :: ScrollEventHandler ( EventHandlerCallRef inHandlerChain, EventRef
if ( err1 == noErr && err2 == noErr && err3 == noErr ) {
nsMacWindow* self = NS_REINTERPRET_CAST(nsMacWindow*, userData);
if ( self ) {
// convert mouse to local coordinates since that's how gecko wants them
// convert mouse to local coordinates since that's how the event handler wants them
StPortSetter portSetter(self->mWindowPtr);
StOriginSetter originSetter(self->mWindowPtr);
::GlobalToLocal(&mouseLoc);
self->mMacEventHandler->Scroll ( axis, delta, mouseLoc );
}