+2006-10-05 Don Gibson <dgibson77@gmail.com>
+
+ 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 <zimmermann@kde.org>
Reviewed and landed by ap.
#define HIGH_BIT_MASK_SHORT 0x8000
static int globalClickCount = 0;
+static enum MouseButton globalPrevClickButton = LeftButton;
static DWORD globalPrevClickTime = 0;
static IntPoint globalPrevClickPosition = IntPoint();
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)
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