From 15da33d9cf65e310d69725fa85ffc6c736c5ab02 Mon Sep 17 00:00:00 2001 From: ap Date: Thu, 5 Oct 2006 17:57:20 +0000 Subject: [PATCH] 2006-10-05 Don Gibson Reviewed by Adam. http://bugs.webkit.org/show_bug.cgi?id=11138 Incorrect mouse event generation on Windows * platform/win/MouseEventWin.cpp: (WebCore::PlatformMouseEvent::PlatformMouseEvent): (1) Set mouse button even for non-click-related messages. (2) Track clicks correctly for all buttons, not just the left button. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16811 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 12 +++++++ WebCore/platform/win/MouseEventWin.cpp | 49 +++++++++++++++++++------- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index e0af2dd12c26..bfe8f97ad698 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2006-10-05 Don Gibson + + Reviewed by Adam. + + http://bugs.webkit.org/show_bug.cgi?id=11138 + Incorrect mouse event generation on Windows + + * platform/win/MouseEventWin.cpp: + (WebCore::PlatformMouseEvent::PlatformMouseEvent): + (1) Set mouse button even for non-click-related messages. + (2) Track clicks correctly for all buttons, not just the left button. + 2006-10-05 Nikolas Zimmermann Reviewed and landed by ap. diff --git a/WebCore/platform/win/MouseEventWin.cpp b/WebCore/platform/win/MouseEventWin.cpp index 69ae05625e27..b33d19e2aa64 100644 --- a/WebCore/platform/win/MouseEventWin.cpp +++ b/WebCore/platform/win/MouseEventWin.cpp @@ -34,6 +34,7 @@ const PlatformMouseEvent::CurrentEventTag PlatformMouseEvent::currentEvent = {}; #define HIGH_BIT_MASK_SHORT 0x8000 static int globalClickCount = 0; +static enum MouseButton globalPrevClickButton = LeftButton; static DWORD globalPrevClickTime = 0; static IntPoint globalPrevClickPosition = IntPoint(); @@ -53,7 +54,6 @@ static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam) PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) : m_position(positionForEvent(hWnd, lParam)) , m_globalPosition(globalPositionForEvent(hWnd, lParam)) - , m_clickCount(0) , m_shiftKey(wParam & MK_SHIFT) , m_ctrlKey(wParam & MK_CONTROL) , m_altKey(GetAsyncKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) @@ -75,20 +75,45 @@ PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, L case WM_MBUTTONDBLCLK: m_button = MiddleButton; break; + default: + if (wParam & MK_LBUTTON) + m_button = LeftButton; + else if (wParam & MK_RBUTTON) + m_button = RightButton; + else if (wParam & MK_MBUTTON) + m_button = MiddleButton; + else + m_button = LeftButton; + break; } - if (m_button == LeftButton) { - DWORD curTime = GetTickCount(); - if (curTime - globalPrevClickTime > GetDoubleClickTime() - || globalPrevClickPosition != m_position) - globalClickCount = 1; - else - globalClickCount++; - - globalPrevClickTime = curTime; - globalPrevClickPosition = m_position; - m_clickCount = globalClickCount; + switch (message) { + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + if (globalPrevClickButton != m_button) + globalClickCount = 0; + // FALL THROUGH + case WM_LBUTTONDBLCLK: // For these messages, the OS ensures that the + case WM_MBUTTONDBLCLK: // previous BUTTONDOWN was for the same button. + case WM_RBUTTONDBLCLK: + { + DWORD curTime = GetTickCount(); + if (curTime - globalPrevClickTime > GetDoubleClickTime() || + m_position != globalPrevClickPosition) + globalClickCount = 0; + globalPrevClickTime = curTime; + } + globalPrevClickButton = m_button; + globalPrevClickPosition = m_position; + m_clickCount = ++globalClickCount; + return; } + + m_clickCount = (m_button == globalPrevClickButton) ? globalClickCount : + ((message == WM_LBUTTONUP || message == WM_MBUTTONUP || + message == WM_RBUTTONUP) ? 1 : 0); + return; } } // namespace WebCore -- 2.36.0