Bug 959171 - Fix how to bind EGLImage in GrallocTextureHostOGL. r=nical
[gecko.git] / widget / TouchEvents.h
blobb912aaa06ea9dd301fc1dcc9a7b3a8d95c50bcde
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_TouchEvents_h__
7 #define mozilla_TouchEvents_h__
9 #include <stdint.h>
11 #include "mozilla/dom/Touch.h"
12 #include "mozilla/MouseEvents.h"
13 #include "nsAutoPtr.h"
14 #include "nsIDOMSimpleGestureEvent.h"
15 #include "nsTArray.h"
17 namespace mozilla {
19 /******************************************************************************
20 * mozilla::WidgetGestureNotifyEvent
22 * This event is the first event generated when the user touches
23 * the screen with a finger, and it's meant to decide what kind
24 * of action we'll use for that touch interaction.
26 * The event is dispatched to the layout and based on what is underneath
27 * the initial contact point it's then decided if we should pan
28 * (finger scrolling) or drag the target element.
29 ******************************************************************************/
31 class WidgetGestureNotifyEvent : public WidgetGUIEvent
33 public:
34 virtual WidgetGestureNotifyEvent* AsGestureNotifyEvent() MOZ_OVERRIDE
36 return this;
39 WidgetGestureNotifyEvent(bool aIsTrusted, uint32_t aMessage,
40 nsIWidget *aWidget) :
41 WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_GESTURENOTIFY_EVENT),
42 panDirection(ePanNone), displayPanFeedback(false)
46 enum ePanDirection
48 ePanNone,
49 ePanVertical,
50 ePanHorizontal,
51 ePanBoth
54 ePanDirection panDirection;
55 bool displayPanFeedback;
57 // XXX Not tested by test_assign_event_data.html
58 void AssignGestureNotifyEventData(const WidgetGestureNotifyEvent& aEvent,
59 bool aCopyTargets)
61 AssignGUIEventData(aEvent, aCopyTargets);
63 panDirection = aEvent.panDirection;
64 displayPanFeedback = aEvent.displayPanFeedback;
68 /******************************************************************************
69 * mozilla::WidgetTouchEvent
70 ******************************************************************************/
72 class WidgetSimpleGestureEvent : public WidgetMouseEventBase
74 public:
75 virtual WidgetSimpleGestureEvent* AsSimpleGestureEvent() MOZ_OVERRIDE
77 return this;
80 WidgetSimpleGestureEvent(bool aIsTrusted, uint32_t aMessage,
81 nsIWidget* aWidget, uint32_t aDirection,
82 double aDelta) :
83 WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
84 NS_SIMPLE_GESTURE_EVENT),
85 allowedDirections(0), direction(aDirection), delta(aDelta), clickCount(0)
89 WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther) :
90 WidgetMouseEventBase(aOther.mFlags.mIsTrusted,
91 aOther.message, aOther.widget,
92 NS_SIMPLE_GESTURE_EVENT),
93 allowedDirections(aOther.allowedDirections), direction(aOther.direction),
94 delta(aOther.delta), clickCount(0)
98 // See nsIDOMSimpleGestureEvent for values
99 uint32_t allowedDirections;
100 // See nsIDOMSimpleGestureEvent for values
101 uint32_t direction;
102 // Delta for magnify and rotate events
103 double delta;
104 // The number of taps for tap events
105 uint32_t clickCount;
107 // XXX Not tested by test_assign_event_data.html
108 void AssignSimpleGestureEventData(const WidgetSimpleGestureEvent& aEvent,
109 bool aCopyTargets)
111 AssignMouseEventBaseData(aEvent, aCopyTargets);
113 // allowedDirections isn't copied
114 direction = aEvent.direction;
115 delta = aEvent.delta;
116 clickCount = aEvent.clickCount;
120 /******************************************************************************
121 * mozilla::WidgetTouchEvent
122 ******************************************************************************/
124 class WidgetTouchEvent : public WidgetInputEvent
126 public:
127 virtual WidgetTouchEvent* AsTouchEvent() MOZ_OVERRIDE { return this; }
129 WidgetTouchEvent()
133 WidgetTouchEvent(const WidgetTouchEvent& aOther) :
134 WidgetInputEvent(aOther.mFlags.mIsTrusted, aOther.message, aOther.widget,
135 NS_TOUCH_EVENT)
137 modifiers = aOther.modifiers;
138 time = aOther.time;
139 touches.AppendElements(aOther.touches);
140 MOZ_COUNT_CTOR(WidgetTouchEvent);
143 WidgetTouchEvent(bool aIsTrusted, WidgetTouchEvent* aEvent) :
144 WidgetInputEvent(aIsTrusted, aEvent->message, aEvent->widget,
145 NS_TOUCH_EVENT)
147 modifiers = aEvent->modifiers;
148 time = aEvent->time;
149 touches.AppendElements(aEvent->touches);
150 MOZ_COUNT_CTOR(WidgetTouchEvent);
153 WidgetTouchEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
154 WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_TOUCH_EVENT)
156 MOZ_COUNT_CTOR(WidgetTouchEvent);
159 virtual ~WidgetTouchEvent()
161 MOZ_COUNT_DTOR(WidgetTouchEvent);
164 nsTArray<nsRefPtr<mozilla::dom::Touch>> touches;
166 void AssignTouchEventData(const WidgetTouchEvent& aEvent, bool aCopyTargets)
168 AssignInputEventData(aEvent, aCopyTargets);
170 // Currently, we don't need to copy touches.
174 } // namespace mozilla
176 #endif // mozilla_TouchEvents_h__