From 99686018e167b56f0e37ee57326d7580048a4880 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 6 Mar 2012 12:20:28 +0900 Subject: [PATCH] Bug 672175 part.8 Compute modifier key state in MouseScrollHandler r=jimm --- widget/windows/WinMouseScrollHandler.cpp | 14 ++++++++++++++ widget/windows/WinMouseScrollHandler.h | 8 ++++++++ widget/windows/nsWindow.cpp | 10 +--------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp index cc4be0b1d88..eb75ee1cc7e 100644 --- a/widget/windows/WinMouseScrollHandler.cpp +++ b/widget/windows/WinMouseScrollHandler.cpp @@ -167,6 +167,20 @@ MouseScrollHandler::DispatchEvent(nsWindow* aWindow, nsGUIEvent& aEvent) return aWindow->DispatchWindowEvent(&aEvent); } +/* static */ +nsModifierKeyState +MouseScrollHandler::GetModifierKeyState() +{ + nsModifierKeyState result; + // Assume the Control key is down if the Elantech touchpad has sent the + // mis-ordered WM_KEYDOWN/WM_MOUSEWHEEL messages. (See the comment in + // MouseScrollHandler::Device::Elantech::HandleKeyMessage().) + if (!result.mIsControlDown) { + result.mIsControlDown = Device::Elantech::IsZooming(); + } + return result; +} + /****************************************************************************** * * EventInfo diff --git a/widget/windows/WinMouseScrollHandler.h b/widget/windows/WinMouseScrollHandler.h index 26ec433c957..d07f1bea748 100644 --- a/widget/windows/WinMouseScrollHandler.h +++ b/widget/windows/WinMouseScrollHandler.h @@ -15,6 +15,7 @@ class nsWindow; class nsGUIEvent; +struct nsModifierKeyState; namespace mozilla { namespace widget { @@ -33,6 +34,13 @@ public: LRESULT *aRetValue, bool &aEatMessage); + /** + * GetModifierKeyState() returns current modifier key state. + * Note that some devices need some hack for the modifier key state. + * This method does it automatically. + */ + static nsModifierKeyState GetModifierKeyState(); + private: MouseScrollHandler(); ~MouseScrollHandler(); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index bc50a7d997a..9344d25b5aa 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6295,21 +6295,13 @@ nsWindow::OnMouseWheelInternal(UINT aMessage, WPARAM aWParam, LPARAM aLParam, // means we process this message *aRetValue = eventInfo.ComputeMessageResult(true); - nsModifierKeyState modKeyState; + nsModifierKeyState modKeyState = MouseScrollHandler::GetModifierKeyState(); // Our positive delta value means to bottom or right. // But positive native delta value means to top or right. // Use orienter for computing our delta value with native delta value. PRInt32 orienter = eventInfo.IsVertical() ? -1 : 1; - // Assume the Control key is down if the Elantech touchpad has sent the - // mis-ordered WM_KEYDOWN/WM_MOUSEWHEEL messages. (See the comment in - // MouseScrollHandler::Device::Elantech::HandleKeyMessage().) - if (!modKeyState.mIsControlDown) { - modKeyState.mIsControlDown = - MouseScrollHandler::Device::Elantech::IsZooming(); - } - // Create line (or page) scroll event. nsMouseScrollEvent scrollEvent(true, NS_MOUSE_SCROLL, this);