2
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3
* Copyright (C) 2007-2008 Torch Mobile Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
14
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#include "PlatformMouseEvent.h"
30
#include <wtf/Assertions.h>
36
#define HIGH_BIT_MASK_SHORT 0x8000
38
static IntPoint positionForEvent(HWND hWnd, LPARAM lParam)
40
POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
44
static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
46
POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
47
ClientToScreen(hWnd, &point);
51
static PlatformEvent::Type messageToEventType(UINT message)
54
case WM_LBUTTONDBLCLK:
55
case WM_RBUTTONDBLCLK:
56
case WM_MBUTTONDBLCLK:
57
//MSDN docs say double click is sent on mouse down
61
return PlatformEvent::MousePressed;
66
return PlatformEvent::MouseReleased;
72
return PlatformEvent::MouseMoved;
76
//Move is relatively harmless
77
return PlatformEvent::MouseMoved;
81
PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool didActivateWebView)
82
: PlatformEvent(messageToEventType(message), wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001)
83
, m_position(positionForEvent(hWnd, lParam))
84
, m_globalPosition(globalPositionForEvent(hWnd, lParam))
86
, m_didActivateWebView(didActivateWebView)
87
, m_modifierFlags(wParam)
92
case WM_LBUTTONDBLCLK:
93
m_button = LeftButton;
97
case WM_RBUTTONDBLCLK:
98
m_button = RightButton;
102
case WM_MBUTTONDBLCLK:
103
m_button = MiddleButton;
109
if (wParam & MK_LBUTTON)
110
m_button = LeftButton;
111
else if (wParam & MK_MBUTTON)
112
m_button = MiddleButton;
113
else if (wParam & MK_RBUTTON)
114
m_button = RightButton;
119
ASSERT_NOT_REACHED();
123
} // namespace WebCore