OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_DISPATCH_CALLBACK_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_DEVICE_EVENT_DISPATCHER_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_DISPATCH_CALLBACK_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_DEVICE_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include "base/callback.h" | |
9 #include "base/time/time.h" | 8 #include "base/time/time.h" |
10 #include "ui/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
11 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 10 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
12 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
13 #include "ui/gfx/geometry/vector2d.h" | 12 #include "ui/gfx/geometry/vector2d.h" |
14 #include "ui/gfx/geometry/vector2d_f.h" | 13 #include "ui/gfx/geometry/vector2d_f.h" |
15 | 14 |
16 namespace base { | |
17 class TimeDelta; | |
18 } | |
19 | |
20 namespace gfx { | |
21 class PointF; | |
22 class Vector2d; | |
23 class Vector2dF; | |
24 } | |
25 | |
26 namespace ui { | 15 namespace ui { |
27 | 16 |
28 class Event; | |
29 | |
30 typedef base::Callback<void(scoped_ptr<Event>)> EventDispatchCallback; | |
31 | |
32 struct EVENTS_OZONE_EVDEV_EXPORT KeyEventParams { | 17 struct EVENTS_OZONE_EVDEV_EXPORT KeyEventParams { |
33 KeyEventParams(int device_id, unsigned int code, bool down); | 18 KeyEventParams(int device_id, unsigned int code, bool down); |
34 KeyEventParams(const KeyEventParams& other); | 19 KeyEventParams(const KeyEventParams& other); |
35 ~KeyEventParams(); | 20 ~KeyEventParams(); |
36 | 21 |
37 int device_id; | 22 int device_id; |
38 unsigned int code; | 23 unsigned int code; |
39 bool down; | 24 bool down; |
40 }; | 25 }; |
41 | 26 |
42 typedef base::Callback<void(const KeyEventParams& params)> | |
43 KeyEventDispatchCallback; | |
44 | |
45 struct EVENTS_OZONE_EVDEV_EXPORT MouseMoveEventParams { | 27 struct EVENTS_OZONE_EVDEV_EXPORT MouseMoveEventParams { |
46 MouseMoveEventParams(int device_id, const gfx::PointF& location); | 28 MouseMoveEventParams(int device_id, const gfx::PointF& location); |
47 MouseMoveEventParams(const MouseMoveEventParams& other); | 29 MouseMoveEventParams(const MouseMoveEventParams& other); |
48 ~MouseMoveEventParams(); | 30 ~MouseMoveEventParams(); |
49 | 31 |
50 int device_id; | 32 int device_id; |
51 gfx::PointF location; | 33 gfx::PointF location; |
52 }; | 34 }; |
53 | 35 |
54 typedef base::Callback<void(const MouseMoveEventParams& params)> | |
55 MouseMoveEventDispatchCallback; | |
56 | |
57 struct EVENTS_OZONE_EVDEV_EXPORT MouseButtonEventParams { | 36 struct EVENTS_OZONE_EVDEV_EXPORT MouseButtonEventParams { |
58 MouseButtonEventParams(int device_id, | 37 MouseButtonEventParams(int device_id, |
59 const gfx::PointF& location, | 38 const gfx::PointF& location, |
60 unsigned int button, | 39 unsigned int button, |
61 bool down, | 40 bool down, |
62 bool allow_remap); | 41 bool allow_remap); |
63 MouseButtonEventParams(const MouseButtonEventParams& other); | 42 MouseButtonEventParams(const MouseButtonEventParams& other); |
64 ~MouseButtonEventParams(); | 43 ~MouseButtonEventParams(); |
65 | 44 |
66 int device_id; | 45 int device_id; |
67 gfx::PointF location; | 46 gfx::PointF location; |
68 unsigned int button; | 47 unsigned int button; |
69 bool down; | 48 bool down; |
70 bool allow_remap; | 49 bool allow_remap; |
71 }; | 50 }; |
72 | 51 |
73 typedef base::Callback<void(const MouseButtonEventParams& params)> | |
74 MouseButtonEventDispatchCallback; | |
75 | |
76 struct EVENTS_OZONE_EVDEV_EXPORT MouseWheelEventParams { | 52 struct EVENTS_OZONE_EVDEV_EXPORT MouseWheelEventParams { |
77 MouseWheelEventParams(int device_id, | 53 MouseWheelEventParams(int device_id, |
78 const gfx::PointF& location, | 54 const gfx::PointF& location, |
79 const gfx::Vector2d& delta); | 55 const gfx::Vector2d& delta); |
80 MouseWheelEventParams(const MouseWheelEventParams& other); | 56 MouseWheelEventParams(const MouseWheelEventParams& other); |
81 ~MouseWheelEventParams(); | 57 ~MouseWheelEventParams(); |
82 | 58 |
83 int device_id; | 59 int device_id; |
84 gfx::PointF location; | 60 gfx::PointF location; |
85 gfx::Vector2d delta; | 61 gfx::Vector2d delta; |
86 }; | 62 }; |
87 | 63 |
88 typedef base::Callback<void(const MouseWheelEventParams& params)> | |
89 MouseWheelEventDispatchCallback; | |
90 | |
91 struct EVENTS_OZONE_EVDEV_EXPORT ScrollEventParams { | 64 struct EVENTS_OZONE_EVDEV_EXPORT ScrollEventParams { |
92 ScrollEventParams(int device_id, | 65 ScrollEventParams(int device_id, |
93 EventType type, | 66 EventType type, |
94 const gfx::PointF location, | 67 const gfx::PointF location, |
95 const gfx::Vector2dF delta, | 68 const gfx::Vector2dF delta, |
96 const gfx::Vector2dF ordinal_delta, | 69 const gfx::Vector2dF ordinal_delta, |
97 int finger_count, | 70 int finger_count, |
98 const base::TimeDelta timestamp); | 71 const base::TimeDelta timestamp); |
99 ScrollEventParams(const ScrollEventParams& other); | 72 ScrollEventParams(const ScrollEventParams& other); |
100 ~ScrollEventParams(); | 73 ~ScrollEventParams(); |
101 | 74 |
102 int device_id; | 75 int device_id; |
103 EventType type; | 76 EventType type; |
104 const gfx::PointF location; | 77 const gfx::PointF location; |
105 const gfx::Vector2dF delta; | 78 const gfx::Vector2dF delta; |
106 const gfx::Vector2dF ordinal_delta; | 79 const gfx::Vector2dF ordinal_delta; |
107 int finger_count; | 80 int finger_count; |
108 const base::TimeDelta timestamp; | 81 const base::TimeDelta timestamp; |
109 }; | 82 }; |
110 | 83 |
111 typedef base::Callback<void(const ScrollEventParams& params)> | |
112 ScrollEventDispatchCallback; | |
113 | |
114 struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams { | 84 struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams { |
115 TouchEventParams(int device_id, | 85 TouchEventParams(int device_id, |
116 int touch_id, | 86 int touch_id, |
117 EventType type, | 87 EventType type, |
118 const gfx::PointF& location, | 88 const gfx::PointF& location, |
119 const gfx::Vector2dF& radii, | 89 const gfx::Vector2dF& radii, |
120 float pressure, | 90 float pressure, |
121 const base::TimeDelta& timestamp); | 91 const base::TimeDelta& timestamp); |
122 TouchEventParams(const TouchEventParams& other); | 92 TouchEventParams(const TouchEventParams& other); |
123 ~TouchEventParams(); | 93 ~TouchEventParams(); |
124 | 94 |
125 int device_id; | 95 int device_id; |
126 int touch_id; | 96 int touch_id; |
127 EventType type; | 97 EventType type; |
128 gfx::PointF location; | 98 gfx::PointF location; |
129 gfx::Vector2dF radii; | 99 gfx::Vector2dF radii; |
130 float pressure; | 100 float pressure; |
131 base::TimeDelta timestamp; | 101 base::TimeDelta timestamp; |
132 }; | 102 }; |
133 | 103 |
134 typedef base::Callback<void(const TouchEventParams& params)> | 104 // Interface used by device objects for event dispatch. |
135 TouchEventDispatchCallback; | 105 class EVENTS_OZONE_EVDEV_EXPORT DeviceEventDispatcherEvdev { |
| 106 public: |
| 107 DeviceEventDispatcherEvdev() {} |
| 108 virtual ~DeviceEventDispatcherEvdev() {} |
136 | 109 |
137 } // namspace ui | 110 virtual void DispatchKeyEvent(const KeyEventParams& params) = 0; |
| 111 virtual void DispatchMouseMoveEvent(const MouseMoveEventParams& params) = 0; |
| 112 virtual void DispatchMouseButtonEvent( |
| 113 const MouseButtonEventParams& params) = 0; |
| 114 virtual void DispatchMouseWheelEvent(const MouseWheelEventParams& params) = 0; |
| 115 virtual void DispatchScrollEvent(const ScrollEventParams& params) = 0; |
| 116 virtual void DispatchTouchEvent(const TouchEventParams& params) = 0; |
| 117 }; |
138 | 118 |
139 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_DISPATCH_CALLBACK_H_ | 119 } // namespace ui |
| 120 |
| 121 #endif // UI_EVENTS_OZONE_EVDEV_DEVICE_EVENT_DISPATCHER_H_ |
OLD | NEW |