| 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 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 | 10 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 radius_x(radius_x > 0 ? radius_x : radius_y), | 526 radius_x(radius_x > 0 ? radius_x : radius_y), |
| 527 radius_y(radius_y > 0 ? radius_y : radius_x), | 527 radius_y(radius_y > 0 ? radius_y : radius_x), |
| 528 force(force), | 528 force(force), |
| 529 tilt_x(tilt_x), | 529 tilt_x(tilt_x), |
| 530 tilt_y(tilt_y), | 530 tilt_y(tilt_y), |
| 531 tangential_pressure(tangential_pressure), | 531 tangential_pressure(tangential_pressure), |
| 532 twist(twist), | 532 twist(twist), |
| 533 id(pointer_id) { | 533 id(pointer_id) { |
| 534 if (pointer_id == PointerDetails::kUnknownPointerId) { | 534 if (pointer_id == PointerDetails::kUnknownPointerId) { |
| 535 id = pointer_type == EventPointerType::POINTER_TYPE_MOUSE | 535 id = pointer_type == EventPointerType::POINTER_TYPE_MOUSE |
| 536 ? PointerEvent::kMousePointerId | 536 ? MouseEvent::kMousePointerId |
| 537 : 0; | 537 : 0; |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 | 540 |
| 541 PointerDetails::PointerDetails(EventPointerType pointer_type, | 541 PointerDetails::PointerDetails(EventPointerType pointer_type, |
| 542 const gfx::Vector2d& pointer_offset, | 542 const gfx::Vector2d& pointer_offset, |
| 543 int pointer_id) | 543 int pointer_id) |
| 544 : PointerDetails(pointer_type, pointer_id) { | 544 : PointerDetails(pointer_type, pointer_id) { |
| 545 offset = pointer_offset; | 545 offset = pointer_offset; |
| 546 } | 546 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 default: | 618 default: |
| 619 NOTREACHED(); | 619 NOTREACHED(); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 | 622 |
| 623 MouseEvent::MouseEvent(EventType type, | 623 MouseEvent::MouseEvent(EventType type, |
| 624 const gfx::Point& location, | 624 const gfx::Point& location, |
| 625 const gfx::Point& root_location, | 625 const gfx::Point& root_location, |
| 626 base::TimeTicks time_stamp, | 626 base::TimeTicks time_stamp, |
| 627 int flags, | 627 int flags, |
| 628 int changed_button_flags) | 628 int changed_button_flags, |
| 629 const PointerDetails& pointer_details) |
| 629 : LocatedEvent(type, | 630 : LocatedEvent(type, |
| 630 gfx::PointF(location), | 631 gfx::PointF(location), |
| 631 gfx::PointF(root_location), | 632 gfx::PointF(root_location), |
| 632 time_stamp, | 633 time_stamp, |
| 633 flags), | 634 flags), |
| 634 changed_button_flags_(changed_button_flags), | 635 changed_button_flags_(changed_button_flags), |
| 635 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { | 636 pointer_details_(pointer_details) { |
| 636 DCHECK_NE(ET_MOUSEWHEEL, type); | 637 DCHECK_NE(ET_MOUSEWHEEL, type); |
| 637 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 638 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 638 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) | 639 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) |
| 639 SetType(ET_MOUSE_DRAGGED); | 640 SetType(ET_MOUSE_DRAGGED); |
| 640 } | 641 } |
| 641 | 642 |
| 642 // static | 643 // static |
| 643 bool MouseEvent::IsRepeatedClickEvent( | 644 bool MouseEvent::IsRepeatedClickEvent( |
| 644 const MouseEvent& event1, | 645 const MouseEvent& event1, |
| 645 const MouseEvent& event2) { | 646 const MouseEvent& event2) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 f &= ~EF_IS_TRIPLE_CLICK; | 751 f &= ~EF_IS_TRIPLE_CLICK; |
| 751 break; | 752 break; |
| 752 case 3: | 753 case 3: |
| 753 f &= ~EF_IS_DOUBLE_CLICK; | 754 f &= ~EF_IS_DOUBLE_CLICK; |
| 754 f |= EF_IS_TRIPLE_CLICK; | 755 f |= EF_IS_TRIPLE_CLICK; |
| 755 break; | 756 break; |
| 756 } | 757 } |
| 757 set_flags(f); | 758 set_flags(f); |
| 758 } | 759 } |
| 759 | 760 |
| 760 void MouseEvent::set_pointer_details(const PointerDetails& details) { | 761 const int MouseEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); |
| 761 DCHECK_NE(EventPointerType::POINTER_TYPE_TOUCH, | |
| 762 pointer_details_.pointer_type); | |
| 763 DCHECK_NE(EventPointerType::POINTER_TYPE_TOUCH, details.pointer_type); | |
| 764 DCHECK(pointer_details_.id == PointerEvent::kMousePointerId || | |
| 765 details.id != PointerEvent::kMousePointerId); | |
| 766 pointer_details_ = details; | |
| 767 } | |
| 768 | 762 |
| 769 //////////////////////////////////////////////////////////////////////////////// | 763 //////////////////////////////////////////////////////////////////////////////// |
| 770 // MouseWheelEvent | 764 // MouseWheelEvent |
| 771 | 765 |
| 772 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event) | 766 MouseWheelEvent::MouseWheelEvent(const base::NativeEvent& native_event) |
| 773 : MouseEvent(native_event), | 767 : MouseEvent(native_event), |
| 774 offset_(GetMouseWheelOffset(native_event)) { | 768 offset_(GetMouseWheelOffset(native_event)) { |
| 775 } | 769 } |
| 776 | 770 |
| 777 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) | 771 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 changed_button_flags_(changed_button_flags), | 1073 changed_button_flags_(changed_button_flags), |
| 1080 details_(pointer_details) { | 1074 details_(pointer_details) { |
| 1081 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) | 1075 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) |
| 1082 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | 1076 latency()->set_source_event_type(ui::SourceEventType::TOUCH); |
| 1083 else if (type == ET_POINTER_WHEEL_CHANGED) | 1077 else if (type == ET_POINTER_WHEEL_CHANGED) |
| 1084 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | 1078 latency()->set_source_event_type(ui::SourceEventType::WHEEL); |
| 1085 else | 1079 else |
| 1086 latency()->set_source_event_type(ui::SourceEventType::OTHER); | 1080 latency()->set_source_event_type(ui::SourceEventType::OTHER); |
| 1087 } | 1081 } |
| 1088 | 1082 |
| 1089 const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); | |
| 1090 | |
| 1091 //////////////////////////////////////////////////////////////////////////////// | 1083 //////////////////////////////////////////////////////////////////////////////// |
| 1092 // KeyEvent | 1084 // KeyEvent |
| 1093 | 1085 |
| 1094 // static | 1086 // static |
| 1095 KeyEvent* KeyEvent::last_key_event_ = NULL; | 1087 KeyEvent* KeyEvent::last_key_event_ = NULL; |
| 1096 | 1088 |
| 1097 // static | 1089 // static |
| 1098 bool KeyEvent::IsRepeated(const KeyEvent& event) { | 1090 bool KeyEvent::IsRepeated(const KeyEvent& event) { |
| 1099 // A safe guard in case if there were continous key pressed events that are | 1091 // A safe guard in case if there were continous key pressed events that are |
| 1100 // not auto repeat. | 1092 // not auto repeat. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 flags | EF_FROM_TOUCH), | 1437 flags | EF_FROM_TOUCH), |
| 1446 details_(details), | 1438 details_(details), |
| 1447 unique_touch_event_id_(unique_touch_event_id) { | 1439 unique_touch_event_id_(unique_touch_event_id) { |
| 1448 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | 1440 latency()->set_source_event_type(ui::SourceEventType::TOUCH); |
| 1449 } | 1441 } |
| 1450 | 1442 |
| 1451 GestureEvent::~GestureEvent() { | 1443 GestureEvent::~GestureEvent() { |
| 1452 } | 1444 } |
| 1453 | 1445 |
| 1454 } // namespace ui | 1446 } // namespace ui |
| OLD | NEW |