| 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/extensions/XInput2.h> |
| 9 #include <X11/keysym.h> | 9 #include <X11/keysym.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 MouseEvent::MouseEvent(const base::NativeEvent& native_event) | 320 MouseEvent::MouseEvent(const base::NativeEvent& native_event) |
| 321 : LocatedEvent(native_event), | 321 : LocatedEvent(native_event), |
| 322 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)), | 322 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)), |
| 323 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { | 323 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { |
| 324 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) | 324 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) |
| 325 SetClickCount(GetRepeatCount(*this)); | 325 SetClickCount(GetRepeatCount(*this)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 MouseEvent::MouseEvent(EventType type, | 328 MouseEvent::MouseEvent(EventType type, |
| 329 const gfx::PointF& location, | 329 const gfx::Point& location, |
| 330 const gfx::PointF& root_location, | 330 const gfx::Point& root_location, |
| 331 base::TimeDelta time_stamp, | 331 base::TimeDelta time_stamp, |
| 332 int flags, | 332 int flags, |
| 333 int changed_button_flags) | 333 int changed_button_flags) |
| 334 : LocatedEvent(type, location, root_location, time_stamp, flags), | 334 : LocatedEvent(type, |
| 335 gfx::PointF(location), |
| 336 gfx::PointF(root_location), |
| 337 time_stamp, |
| 338 flags), |
| 335 changed_button_flags_(changed_button_flags), | 339 changed_button_flags_(changed_button_flags), |
| 336 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { | 340 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { |
| 337 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) | 341 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) |
| 338 SetType(ET_MOUSE_DRAGGED); | 342 SetType(ET_MOUSE_DRAGGED); |
| 339 } | 343 } |
| 340 | 344 |
| 341 // static | 345 // static |
| 342 bool MouseEvent::IsRepeatedClickEvent( | 346 bool MouseEvent::IsRepeatedClickEvent( |
| 343 const MouseEvent& event1, | 347 const MouseEvent& event1, |
| 344 const MouseEvent& event2) { | 348 const MouseEvent& event2) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 DCHECK(type() == ET_MOUSEWHEEL); | 482 DCHECK(type() == ET_MOUSEWHEEL); |
| 479 } | 483 } |
| 480 | 484 |
| 481 MouseWheelEvent::MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event) | 485 MouseWheelEvent::MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event) |
| 482 : MouseEvent(mouse_wheel_event), | 486 : MouseEvent(mouse_wheel_event), |
| 483 offset_(mouse_wheel_event.offset()) { | 487 offset_(mouse_wheel_event.offset()) { |
| 484 DCHECK(type() == ET_MOUSEWHEEL); | 488 DCHECK(type() == ET_MOUSEWHEEL); |
| 485 } | 489 } |
| 486 | 490 |
| 487 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, | 491 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, |
| 488 const gfx::PointF& location, | 492 const gfx::Point& location, |
| 489 const gfx::PointF& root_location, | 493 const gfx::Point& root_location, |
| 490 base::TimeDelta time_stamp, | 494 base::TimeDelta time_stamp, |
| 491 int flags, | 495 int flags, |
| 492 int changed_button_flags) | 496 int changed_button_flags) |
| 493 : MouseEvent(ui::ET_MOUSEWHEEL, | 497 : MouseEvent(ui::ET_MOUSEWHEEL, |
| 494 location, | 498 location, |
| 495 root_location, | 499 root_location, |
| 496 time_stamp, | 500 time_stamp, |
| 497 flags, | 501 flags, |
| 498 changed_button_flags), | 502 changed_button_flags), |
| 499 offset_(offset) { | 503 offset_(offset) {} |
| 500 } | |
| 501 | 504 |
| 502 #if defined(OS_WIN) | 505 #if defined(OS_WIN) |
| 503 // This value matches windows WHEEL_DELTA. | 506 // This value matches windows WHEEL_DELTA. |
| 504 // static | 507 // static |
| 505 const int MouseWheelEvent::kWheelDelta = 120; | 508 const int MouseWheelEvent::kWheelDelta = 120; |
| 506 #else | 509 #else |
| 507 // This value matches GTK+ wheel scroll amount. | 510 // This value matches GTK+ wheel scroll amount. |
| 508 const int MouseWheelEvent::kWheelDelta = 53; | 511 const int MouseWheelEvent::kWheelDelta = 53; |
| 509 #endif | 512 #endif |
| 510 | 513 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 528 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, | 531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, |
| 529 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); | 532 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); |
| 530 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 533 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 531 | 534 |
| 532 FixRotationAngle(); | 535 FixRotationAngle(); |
| 533 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) | 536 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) |
| 534 should_remove_native_touch_id_mapping_ = true; | 537 should_remove_native_touch_id_mapping_ = true; |
| 535 } | 538 } |
| 536 | 539 |
| 537 TouchEvent::TouchEvent(EventType type, | 540 TouchEvent::TouchEvent(EventType type, |
| 538 const gfx::PointF& location, | 541 const gfx::Point& location, |
| 539 int touch_id, | 542 int touch_id, |
| 540 base::TimeDelta time_stamp) | 543 base::TimeDelta time_stamp) |
| 541 : LocatedEvent(type, location, location, time_stamp, 0), | 544 : LocatedEvent(type, |
| 545 gfx::PointF(location), |
| 546 gfx::PointF(location), |
| 547 time_stamp, |
| 548 0), |
| 542 touch_id_(touch_id), | 549 touch_id_(touch_id), |
| 543 unique_event_id_(ui::GetNextTouchEventId()), | 550 unique_event_id_(ui::GetNextTouchEventId()), |
| 544 rotation_angle_(0.0f), | 551 rotation_angle_(0.0f), |
| 545 may_cause_scrolling_(false), | 552 may_cause_scrolling_(false), |
| 546 should_remove_native_touch_id_mapping_(false), | 553 should_remove_native_touch_id_mapping_(false), |
| 547 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH)) { | 554 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH)) { |
| 548 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 555 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 549 } | 556 } |
| 550 | 557 |
| 551 TouchEvent::TouchEvent(EventType type, | 558 TouchEvent::TouchEvent(EventType type, |
| 552 const gfx::PointF& location, | 559 const gfx::Point& location, |
| 553 int flags, | 560 int flags, |
| 554 int touch_id, | 561 int touch_id, |
| 555 base::TimeDelta time_stamp, | 562 base::TimeDelta time_stamp, |
| 556 float radius_x, | 563 float radius_x, |
| 557 float radius_y, | 564 float radius_y, |
| 558 float angle, | 565 float angle, |
| 559 float force) | 566 float force) |
| 560 : LocatedEvent(type, location, location, time_stamp, flags), | 567 : LocatedEvent(type, |
| 568 gfx::PointF(location), |
| 569 gfx::PointF(location), |
| 570 time_stamp, |
| 571 flags), |
| 561 touch_id_(touch_id), | 572 touch_id_(touch_id), |
| 562 unique_event_id_(ui::GetNextTouchEventId()), | 573 unique_event_id_(ui::GetNextTouchEventId()), |
| 563 rotation_angle_(angle), | 574 rotation_angle_(angle), |
| 564 may_cause_scrolling_(false), | 575 may_cause_scrolling_(false), |
| 565 should_remove_native_touch_id_mapping_(false), | 576 should_remove_native_touch_id_mapping_(false), |
| 566 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH, | 577 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 567 radius_x, | 578 radius_x, |
| 568 radius_y, | 579 radius_y, |
| 569 force, | 580 force, |
| 570 /* tilt_x */ 0.0f, | 581 /* tilt_x */ 0.0f, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 &x_offset_, &y_offset_, | 930 &x_offset_, &y_offset_, |
| 920 &x_offset_ordinal_, &y_offset_ordinal_, | 931 &x_offset_ordinal_, &y_offset_ordinal_, |
| 921 NULL); | 932 NULL); |
| 922 } else { | 933 } else { |
| 923 NOTREACHED() << "Unexpected event type " << type() | 934 NOTREACHED() << "Unexpected event type " << type() |
| 924 << " when constructing a ScrollEvent."; | 935 << " when constructing a ScrollEvent."; |
| 925 } | 936 } |
| 926 } | 937 } |
| 927 | 938 |
| 928 ScrollEvent::ScrollEvent(EventType type, | 939 ScrollEvent::ScrollEvent(EventType type, |
| 929 const gfx::PointF& location, | 940 const gfx::Point& location, |
| 930 base::TimeDelta time_stamp, | 941 base::TimeDelta time_stamp, |
| 931 int flags, | 942 int flags, |
| 932 float x_offset, | 943 float x_offset, |
| 933 float y_offset, | 944 float y_offset, |
| 934 float x_offset_ordinal, | 945 float x_offset_ordinal, |
| 935 float y_offset_ordinal, | 946 float y_offset_ordinal, |
| 936 int finger_count) | 947 int finger_count) |
| 937 : MouseEvent(type, location, location, time_stamp, flags, 0), | 948 : MouseEvent(type, location, location, time_stamp, flags, 0), |
| 938 x_offset_(x_offset), | 949 x_offset_(x_offset), |
| 939 y_offset_(y_offset), | 950 y_offset_(y_offset), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 963 gfx::PointF(x, y), | 974 gfx::PointF(x, y), |
| 964 time_stamp, | 975 time_stamp, |
| 965 flags | EF_FROM_TOUCH), | 976 flags | EF_FROM_TOUCH), |
| 966 details_(details) { | 977 details_(details) { |
| 967 } | 978 } |
| 968 | 979 |
| 969 GestureEvent::~GestureEvent() { | 980 GestureEvent::~GestureEvent() { |
| 970 } | 981 } |
| 971 | 982 |
| 972 } // namespace ui | 983 } // namespace ui |
| OLD | NEW |