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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 | 430 |
430 //////////////////////////////////////////////////////////////////////////////// | 431 //////////////////////////////////////////////////////////////////////////////// |
431 // TouchEvent | 432 // TouchEvent |
432 | 433 |
433 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | 434 TouchEvent::TouchEvent(const base::NativeEvent& native_event) |
434 : LocatedEvent(native_event), | 435 : LocatedEvent(native_event), |
435 touch_id_(GetTouchId(native_event)), | 436 touch_id_(GetTouchId(native_event)), |
436 radius_x_(GetTouchRadiusX(native_event)), | 437 radius_x_(GetTouchRadiusX(native_event)), |
437 radius_y_(GetTouchRadiusY(native_event)), | 438 radius_y_(GetTouchRadiusY(native_event)), |
438 rotation_angle_(GetTouchAngle(native_event)), | 439 rotation_angle_(GetTouchAngle(native_event)), |
439 force_(GetTouchForce(native_event)) { | 440 force_(GetTouchForce(native_event)), |
441 source_device_id_(-1) { | |
440 latency()->AddLatencyNumberWithTimestamp( | 442 latency()->AddLatencyNumberWithTimestamp( |
441 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 443 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
442 0, | 444 0, |
443 0, | 445 0, |
444 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), | 446 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), |
445 1, | 447 1, |
446 true); | 448 true); |
449 | |
450 #if defined(USE_X11) | |
451 XIEvent* event = static_cast<XIEvent*>(native_event->xcookie.data); | |
452 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); | |
sadrul
2014/01/08 20:50:52
You don't need XIEvent. Just directly static_cast<
tdresser
2014/01/09 19:07:35
Done.
| |
453 source_device_id_ = xiev->deviceid; | |
454 #endif | |
455 | |
447 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 456 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
448 } | 457 } |
449 | 458 |
450 TouchEvent::TouchEvent(EventType type, | 459 TouchEvent::TouchEvent(EventType type, |
451 const gfx::Point& location, | 460 const gfx::Point& location, |
452 int touch_id, | 461 int touch_id, |
453 base::TimeDelta time_stamp) | 462 base::TimeDelta time_stamp) |
454 : LocatedEvent(type, location, location, time_stamp, 0), | 463 : LocatedEvent(type, location, location, time_stamp, 0), |
455 touch_id_(touch_id), | 464 touch_id_(touch_id), |
456 radius_x_(0.0f), | 465 radius_x_(0.0f), |
457 radius_y_(0.0f), | 466 radius_y_(0.0f), |
458 rotation_angle_(0.0f), | 467 rotation_angle_(0.0f), |
459 force_(0.0f) { | 468 force_(0.0f), |
469 source_device_id_(-1) { | |
460 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 470 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
461 } | 471 } |
462 | 472 |
463 TouchEvent::TouchEvent(EventType type, | 473 TouchEvent::TouchEvent(EventType type, |
464 const gfx::Point& location, | 474 const gfx::Point& location, |
465 int flags, | 475 int flags, |
466 int touch_id, | 476 int touch_id, |
467 base::TimeDelta time_stamp, | 477 base::TimeDelta time_stamp, |
468 float radius_x, | 478 float radius_x, |
469 float radius_y, | 479 float radius_y, |
470 float angle, | 480 float angle, |
471 float force) | 481 float force) |
472 : LocatedEvent(type, location, location, time_stamp, flags), | 482 : LocatedEvent(type, location, location, time_stamp, flags), |
473 touch_id_(touch_id), | 483 touch_id_(touch_id), |
474 radius_x_(radius_x), | 484 radius_x_(radius_x), |
475 radius_y_(radius_y), | 485 radius_y_(radius_y), |
476 rotation_angle_(angle), | 486 rotation_angle_(angle), |
477 force_(force) { | 487 force_(force), |
488 source_device_id_(-1){ | |
sadrul
2014/01/08 20:50:52
space before {
tdresser
2014/01/09 19:07:35
Done.
| |
478 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 489 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
479 } | 490 } |
480 | 491 |
481 TouchEvent::~TouchEvent() { | 492 TouchEvent::~TouchEvent() { |
482 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 | 493 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 |
483 // 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, |
484 // 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. |
485 if (HasNativeEvent()) | 496 if (HasNativeEvent()) |
486 ClearTouchIdIfReleased(native_event()); | 497 ClearTouchIdIfReleased(native_event()); |
487 } | 498 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 int GestureEvent::GetLowestTouchId() const { | 717 int GestureEvent::GetLowestTouchId() const { |
707 if (touch_ids_bitfield_ == 0) | 718 if (touch_ids_bitfield_ == 0) |
708 return -1; | 719 return -1; |
709 int i = -1; | 720 int i = -1; |
710 // Find the index of the least significant 1 bit | 721 // Find the index of the least significant 1 bit |
711 while (!(1 << ++i & touch_ids_bitfield_)); | 722 while (!(1 << ++i & touch_ids_bitfield_)); |
712 return i; | 723 return i; |
713 } | 724 } |
714 | 725 |
715 } // namespace ui | 726 } // namespace ui |
OLD | NEW |