OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/base/events/event.h" | 5 #include "ui/base/events/event.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); | 146 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); |
147 CHECK(cancelable_); | 147 CHECK(cancelable_); |
148 result_ = static_cast<EventResult>(result_ | ER_HANDLED); | 148 result_ = static_cast<EventResult>(result_ | ER_HANDLED); |
149 } | 149 } |
150 | 150 |
151 Event::Event(EventType type, base::TimeDelta time_stamp, int flags) | 151 Event::Event(EventType type, base::TimeDelta time_stamp, int flags) |
152 : type_(type), | 152 : type_(type), |
153 time_stamp_(time_stamp), | 153 time_stamp_(time_stamp), |
154 flags_(flags), | 154 flags_(flags), |
155 dispatch_to_hidden_targets_(false), | 155 dispatch_to_hidden_targets_(false), |
| 156 #if defined(USE_X11) |
| 157 native_event_(NULL), |
| 158 #endif |
156 delete_native_event_(false), | 159 delete_native_event_(false), |
157 cancelable_(true), | 160 cancelable_(true), |
158 target_(NULL), | 161 target_(NULL), |
159 phase_(EP_PREDISPATCH), | 162 phase_(EP_PREDISPATCH), |
160 result_(ER_UNHANDLED) { | 163 result_(ER_UNHANDLED) { |
161 if (type_ < ET_LAST) | 164 if (type_ < ET_LAST) |
162 name_ = EventTypeName(type_); | 165 name_ = EventTypeName(type_); |
163 Init(); | 166 Init(); |
164 } | 167 } |
165 | 168 |
(...skipping 21 matching lines...) Expand all Loading... |
187 name_for_event, | 190 name_for_event, |
188 0, | 191 0, |
189 1000000, | 192 1000000, |
190 100, | 193 100, |
191 base::HistogramBase::kUmaTargetedHistogramFlag); | 194 base::HistogramBase::kUmaTargetedHistogramFlag); |
192 counter_for_type->Add(delta.InMicroseconds()); | 195 counter_for_type->Add(delta.InMicroseconds()); |
193 InitWithNativeEvent(native_event); | 196 InitWithNativeEvent(native_event); |
194 } | 197 } |
195 | 198 |
196 Event::Event(const Event& copy) | 199 Event::Event(const Event& copy) |
197 : native_event_(::CopyNativeEvent(copy.native_event_)), | 200 : type_(copy.type_), |
198 type_(copy.type_), | |
199 time_stamp_(copy.time_stamp_), | 201 time_stamp_(copy.time_stamp_), |
200 flags_(copy.flags_), | 202 flags_(copy.flags_), |
201 dispatch_to_hidden_targets_(false), | 203 dispatch_to_hidden_targets_(false), |
| 204 native_event_(::CopyNativeEvent(copy.native_event_)), |
202 delete_native_event_(false), | 205 delete_native_event_(false), |
203 cancelable_(true), | 206 cancelable_(true), |
204 target_(NULL), | 207 target_(NULL), |
205 phase_(EP_PREDISPATCH), | 208 phase_(EP_PREDISPATCH), |
206 result_(ER_UNHANDLED) { | 209 result_(ER_UNHANDLED) { |
207 if (type_ < ET_LAST) | 210 if (type_ < ET_LAST) |
208 name_ = EventTypeName(type_); | 211 name_ = EventTypeName(type_); |
209 #if defined(USE_X11) | 212 #if defined(USE_X11) |
210 if (native_event_) | 213 if (native_event_) |
211 delete_native_event_ = true; | 214 delete_native_event_ = true; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // LocatedEvent | 246 // LocatedEvent |
244 | 247 |
245 LocatedEvent::~LocatedEvent() { | 248 LocatedEvent::~LocatedEvent() { |
246 } | 249 } |
247 | 250 |
248 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) | 251 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) |
249 : Event(native_event, | 252 : Event(native_event, |
250 EventTypeFromNative(native_event), | 253 EventTypeFromNative(native_event), |
251 EventFlagsFromNative(native_event)), | 254 EventFlagsFromNative(native_event)), |
252 location_(EventLocationFromNative(native_event)), | 255 location_(EventLocationFromNative(native_event)), |
253 root_location_(location_), | 256 root_location_(location_) { |
254 valid_system_location_(true), | |
255 system_location_(EventSystemLocationFromNative(native_event)) { | |
256 } | 257 } |
257 | 258 |
258 LocatedEvent::LocatedEvent(EventType type, | 259 LocatedEvent::LocatedEvent(EventType type, |
259 const gfx::Point& location, | 260 const gfx::Point& location, |
260 const gfx::Point& root_location, | 261 const gfx::Point& root_location, |
261 base::TimeDelta time_stamp, | 262 base::TimeDelta time_stamp, |
262 int flags) | 263 int flags) |
263 : Event(type, time_stamp, flags), | 264 : Event(type, time_stamp, flags), |
264 location_(location), | 265 location_(location), |
265 root_location_(root_location), | 266 root_location_(root_location) { |
266 valid_system_location_(false), | |
267 system_location_(0, 0) { | |
268 } | 267 } |
269 | 268 |
270 void LocatedEvent::UpdateForRootTransform( | 269 void LocatedEvent::UpdateForRootTransform( |
271 const gfx::Transform& reversed_root_transform) { | 270 const gfx::Transform& reversed_root_transform) { |
272 // Transform has to be done at root level. | 271 // Transform has to be done at root level. |
273 gfx::Point3F p(location_); | 272 gfx::Point3F p(location_); |
274 reversed_root_transform.TransformPoint(p); | 273 reversed_root_transform.TransformPoint(p); |
275 root_location_ = location_ = gfx::ToFlooredPoint(p.AsPointF()); | 274 root_location_ = location_ = gfx::ToFlooredPoint(p.AsPointF()); |
276 } | 275 } |
277 | 276 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 int GestureEvent::GetLowestTouchId() const { | 727 int GestureEvent::GetLowestTouchId() const { |
729 if (touch_ids_bitfield_ == 0) | 728 if (touch_ids_bitfield_ == 0) |
730 return -1; | 729 return -1; |
731 int i = -1; | 730 int i = -1; |
732 // Find the index of the least significant 1 bit | 731 // Find the index of the least significant 1 bit |
733 while (!(1 << ++i & touch_ids_bitfield_)); | 732 while (!(1 << ++i & touch_ids_bitfield_)); |
734 return i; | 733 return i; |
735 } | 734 } |
736 | 735 |
737 } // namespace ui | 736 } // namespace ui |
OLD | NEW |