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