2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef PlatformMouseEvent_h
27 #define PlatformMouseEvent_h
29 #include "platform/PlatformEvent.h"
30 #include "platform/geometry/IntPoint.h"
34 // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified.
35 enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
37 class PlatformMouseEvent : public PlatformEvent {
39 enum SyntheticEventType {
40 // Real mouse input events or synthetic events that behave just like real events
41 RealOrIndistinguishable,
42 // Mouse events derived from touch input
47 : PlatformEvent(PlatformEvent::MouseMoved)
50 , m_synthesized(RealOrIndistinguishable)
55 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, double timestamp)
56 : PlatformEvent(type, modifiers, timestamp)
57 , m_position(position)
58 , m_globalPosition(globalPosition)
60 , m_clickCount(clickCount)
61 , m_synthesized(RealOrIndistinguishable)
66 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, SyntheticEventType synthesized, double timestamp)
67 : PlatformEvent(type, modifiers, timestamp)
68 , m_position(position)
69 , m_globalPosition(globalPosition)
71 , m_clickCount(clickCount)
72 , m_synthesized(synthesized)
77 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, SyntheticEventType synthesized, double timestamp)
78 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
79 , m_position(position)
80 , m_globalPosition(globalPosition)
82 , m_clickCount(clickCount)
83 , m_synthesized(synthesized)
88 const IntPoint& position() const { return m_position; }
89 const IntPoint& globalPosition() const { return m_globalPosition; }
90 const IntPoint& movementDelta() const { return m_movementDelta; }
92 MouseButton button() const { return m_button; }
93 int clickCount() const { return m_clickCount; }
94 unsigned modifierFlags() const { return m_modifierFlags; }
95 bool fromTouch() const { return m_synthesized == FromTouch; }
96 SyntheticEventType syntheticEventType() const { return m_synthesized; }
100 IntPoint m_globalPosition;
101 IntPoint m_movementDelta;
102 MouseButton m_button;
104 SyntheticEventType m_synthesized;
105 unsigned m_modifierFlags;
110 #endif // PlatformMouseEvent_h