From a1c69ef130871956de692ee06b17e919b3d6c33d Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Wed, 23 Apr 2008 22:51:27 +0000 Subject: [PATCH] Bug 428680: Sometimes, the document node is the event target for mousemove events now, patch by Matthew Gregan , r=smaug, sr=roc, a=damon --- content/events/src/nsEventStateManager.cpp | 9 +++++---- widget/src/windows/nsWindow.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index e1c7cdbb5f5..49d45ecc569 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -833,10 +833,11 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, { nsMouseEvent* mouseEvent = static_cast(aEvent); if (mouseEvent->exit != nsMouseEvent::eTopLevel) { - // treat it as a move so we don't generate spurious "exit" - // events Any necessary exit events will be generated by - // GenerateMouseEnterExit - aEvent->message = NS_MOUSE_MOVE; + // Treat it as a synthetic move so we don't generate spurious + // "exit" or "move" events. Any necessary "out" or "over" events + // will be generated by GenerateMouseEnterExit + mouseEvent->message = NS_MOUSE_MOVE; + mouseEvent->reason = nsMouseEvent::eSynthesized; // then fall through... } else { GenerateMouseEnterExit((nsGUIEvent*)aEvent); diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 7e1b7187c93..eddf5436147 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -5740,7 +5740,15 @@ static PRBool IsTopLevelMouseExit(HWND aWnd) POINT mp; mp.x = GET_X_LPARAM(pos); mp.y = GET_Y_LPARAM(pos); - HWND mouseTopLevel = nsWindow::GetTopLevelHWND(::WindowFromPoint(mp)); + HWND mouseWnd = ::WindowFromPoint(mp); + + // GetTopLevelHWND will return a HWND for the window frame (which includes + // the non-client area). If the mouse has moved into the non-client area, + // we should treat it as a top-level exit. + HWND mouseTopLevel = nsWindow::GetTopLevelHWND(mouseWnd, false); + if (mouseWnd == mouseTopLevel) + return PR_TRUE; + return nsWindow::GetTopLevelHWND(aWnd) != mouseTopLevel; }