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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 base::TimeDelta time_stamp) | 300 base::TimeDelta time_stamp) |
301 : LocatedEvent(type, location, location, 0), | 301 : LocatedEvent(type, location, location, 0), |
302 touch_id_(touch_id), | 302 touch_id_(touch_id), |
303 radius_x_(0.0f), | 303 radius_x_(0.0f), |
304 radius_y_(0.0f), | 304 radius_y_(0.0f), |
305 rotation_angle_(0.0f), | 305 rotation_angle_(0.0f), |
306 force_(0.0f) { | 306 force_(0.0f) { |
307 set_time_stamp(time_stamp); | 307 set_time_stamp(time_stamp); |
308 } | 308 } |
309 | 309 |
| 310 TouchEvent::TouchEvent(EventType type, |
| 311 const gfx::Point& location, |
| 312 int flags, |
| 313 int touch_id, |
| 314 base::TimeDelta timestamp, |
| 315 float radius_x, |
| 316 float radius_y, |
| 317 float angle, |
| 318 float force) |
| 319 : LocatedEvent(type, location, location, flags), |
| 320 touch_id_(touch_id), |
| 321 radius_x_(radius_x), |
| 322 radius_y_(radius_y), |
| 323 rotation_angle_(angle), |
| 324 force_(force) { |
| 325 } |
| 326 |
310 TouchEvent::~TouchEvent() { | 327 TouchEvent::~TouchEvent() { |
311 } | 328 } |
312 | 329 |
313 void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) { | 330 void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) { |
314 location_ = CalibratePoint(location_, from, to); | 331 location_ = CalibratePoint(location_, from, to); |
315 root_location_ = CalibratePoint(root_location_, from, to); | 332 root_location_ = CalibratePoint(root_location_, from, to); |
316 } | 333 } |
317 | 334 |
318 void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { | 335 void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { |
319 LocatedEvent::UpdateForRootTransform(root_transform); | 336 LocatedEvent::UpdateForRootTransform(root_transform); |
320 gfx::Point3f scale; | 337 gfx::Point3f scale; |
321 InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); | 338 InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); |
322 if (scale.x()) | 339 if (scale.x()) |
323 radius_x_ /= scale.x(); | 340 radius_x_ /= scale.x(); |
324 if (scale.y()) | 341 if (scale.y()) |
325 radius_y_ /= scale.y(); | 342 radius_y_ /= scale.y(); |
326 } | 343 } |
327 | 344 |
328 //////////////////////////////////////////////////////////////////////////////// | 345 //////////////////////////////////////////////////////////////////////////////// |
329 // TestTouchEvent | |
330 | |
331 TestTouchEvent::TestTouchEvent(EventType type, | |
332 int x, | |
333 int y, | |
334 int flags, | |
335 int touch_id, | |
336 float radius_x, | |
337 float radius_y, | |
338 float angle, | |
339 float force) | |
340 : TouchEvent(type, gfx::Point(x, y), touch_id, base::TimeDelta()) { | |
341 set_flags(flags); | |
342 set_radius(radius_x, radius_y); | |
343 set_rotation_angle(angle); | |
344 set_force(force); | |
345 } | |
346 | |
347 //////////////////////////////////////////////////////////////////////////////// | |
348 // KeyEvent | 346 // KeyEvent |
349 | 347 |
350 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) | 348 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) |
351 : Event(native_event, | 349 : Event(native_event, |
352 EventTypeFromNative(native_event), | 350 EventTypeFromNative(native_event), |
353 EventFlagsFromNative(native_event)), | 351 EventFlagsFromNative(native_event)), |
354 key_code_(KeyboardCodeFromNative(native_event)), | 352 key_code_(KeyboardCodeFromNative(native_event)), |
355 is_char_(is_char), | 353 is_char_(is_char), |
356 character_(0), | 354 character_(0), |
357 unmodified_character_(0) { | 355 unmodified_character_(0) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 int GestureEvent::GetLowestTouchId() const { | 514 int GestureEvent::GetLowestTouchId() const { |
517 if (touch_ids_bitfield_ == 0) | 515 if (touch_ids_bitfield_ == 0) |
518 return -1; | 516 return -1; |
519 int i = -1; | 517 int i = -1; |
520 // Find the index of the least significant 1 bit | 518 // Find the index of the least significant 1 bit |
521 while (!(1 << ++i & touch_ids_bitfield_)); | 519 while (!(1 << ++i & touch_ids_bitfield_)); |
522 return i; | 520 return i; |
523 } | 521 } |
524 | 522 |
525 } // namespace ui | 523 } // namespace ui |
OLD | NEW |