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/events/event.h" | 5 #include "ui/events/event.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/extensions/XInput2.h> | |
9 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
10 #endif | 9 #endif |
11 | 10 |
12 #include <cmath> | 11 #include <cmath> |
13 #include <cstring> | 12 #include <cstring> |
14 | 13 |
15 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
16 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
17 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
18 #include "ui/events/keycodes/keyboard_code_conversion.h" | 17 #include "ui/events/keycodes/keyboard_code_conversion.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 430 |
432 //////////////////////////////////////////////////////////////////////////////// | 431 //////////////////////////////////////////////////////////////////////////////// |
433 // TouchEvent | 432 // TouchEvent |
434 | 433 |
435 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | 434 TouchEvent::TouchEvent(const base::NativeEvent& native_event) |
436 : LocatedEvent(native_event), | 435 : LocatedEvent(native_event), |
437 touch_id_(GetTouchId(native_event)), | 436 touch_id_(GetTouchId(native_event)), |
438 radius_x_(GetTouchRadiusX(native_event)), | 437 radius_x_(GetTouchRadiusX(native_event)), |
439 radius_y_(GetTouchRadiusY(native_event)), | 438 radius_y_(GetTouchRadiusY(native_event)), |
440 rotation_angle_(GetTouchAngle(native_event)), | 439 rotation_angle_(GetTouchAngle(native_event)), |
441 force_(GetTouchForce(native_event)), | 440 force_(GetTouchForce(native_event)) { |
442 source_device_id_(-1) { | |
443 latency()->AddLatencyNumberWithTimestamp( | 441 latency()->AddLatencyNumberWithTimestamp( |
444 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 442 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
445 0, | 443 0, |
446 0, | 444 0, |
447 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), | 445 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), |
448 1, | 446 1, |
449 true); | 447 true); |
450 | |
451 #if defined(USE_X11) | |
452 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(native_event->xcookie.data); | |
453 source_device_id_ = xiev->deviceid; | |
454 #endif | |
455 | |
456 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 448 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
457 } | 449 } |
458 | 450 |
459 TouchEvent::TouchEvent(EventType type, | 451 TouchEvent::TouchEvent(EventType type, |
460 const gfx::Point& location, | 452 const gfx::Point& location, |
461 int touch_id, | 453 int touch_id, |
462 base::TimeDelta time_stamp) | 454 base::TimeDelta time_stamp) |
463 : LocatedEvent(type, location, location, time_stamp, 0), | 455 : LocatedEvent(type, location, location, time_stamp, 0), |
464 touch_id_(touch_id), | 456 touch_id_(touch_id), |
465 radius_x_(0.0f), | 457 radius_x_(0.0f), |
466 radius_y_(0.0f), | 458 radius_y_(0.0f), |
467 rotation_angle_(0.0f), | 459 rotation_angle_(0.0f), |
468 force_(0.0f), | 460 force_(0.0f) { |
469 source_device_id_(-1) { | |
470 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 461 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
471 } | 462 } |
472 | 463 |
473 TouchEvent::TouchEvent(EventType type, | 464 TouchEvent::TouchEvent(EventType type, |
474 const gfx::Point& location, | 465 const gfx::Point& location, |
475 int flags, | 466 int flags, |
476 int touch_id, | 467 int touch_id, |
477 base::TimeDelta time_stamp, | 468 base::TimeDelta time_stamp, |
478 float radius_x, | 469 float radius_x, |
479 float radius_y, | 470 float radius_y, |
480 float angle, | 471 float angle, |
481 float force) | 472 float force) |
482 : LocatedEvent(type, location, location, time_stamp, flags), | 473 : LocatedEvent(type, location, location, time_stamp, flags), |
483 touch_id_(touch_id), | 474 touch_id_(touch_id), |
484 radius_x_(radius_x), | 475 radius_x_(radius_x), |
485 radius_y_(radius_y), | 476 radius_y_(radius_y), |
486 rotation_angle_(angle), | 477 rotation_angle_(angle), |
487 force_(force), | 478 force_(force) { |
488 source_device_id_(-1) { | |
489 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 479 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
490 } | 480 } |
491 | 481 |
492 TouchEvent::~TouchEvent() { | 482 TouchEvent::~TouchEvent() { |
493 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 | 483 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 |
494 // platform setups the tracking_id to slot mapping. So in dtor here, | 484 // platform setups the tracking_id to slot mapping. So in dtor here, |
495 // if this touch event is a release event, we clear the mapping accordingly. | 485 // if this touch event is a release event, we clear the mapping accordingly. |
496 if (HasNativeEvent()) | 486 if (HasNativeEvent()) |
497 ClearTouchIdIfReleased(native_event()); | 487 ClearTouchIdIfReleased(native_event()); |
498 } | 488 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 int GestureEvent::GetLowestTouchId() const { | 707 int GestureEvent::GetLowestTouchId() const { |
718 if (touch_ids_bitfield_ == 0) | 708 if (touch_ids_bitfield_ == 0) |
719 return -1; | 709 return -1; |
720 int i = -1; | 710 int i = -1; |
721 // Find the index of the least significant 1 bit | 711 // Find the index of the least significant 1 bit |
722 while (!(1 << ++i & touch_ids_bitfield_)); | 712 while (!(1 << ++i & touch_ids_bitfield_)); |
723 return i; | 713 return i; |
724 } | 714 } |
725 | 715 |
726 } // namespace ui | 716 } // namespace ui |
OLD | NEW |