| 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/base/events/event.h" | 5 #include "ui/base/events/event.h" |
| 6 | 6 |
| 7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) | 237 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) |
| 238 : Event(native_event, | 238 : Event(native_event, |
| 239 EventTypeFromNative(native_event), | 239 EventTypeFromNative(native_event), |
| 240 EventFlagsFromNative(native_event)), | 240 EventFlagsFromNative(native_event)), |
| 241 location_(EventLocationFromNative(native_event)), | 241 location_(EventLocationFromNative(native_event)), |
| 242 root_location_(location_), | 242 root_location_(location_), |
| 243 valid_system_location_(true), | 243 valid_system_location_(true), |
| 244 system_location_(ui::EventSystemLocationFromNative(native_event)) { | 244 system_location_(ui::EventSystemLocationFromNative(native_event)) { |
| 245 } | 245 } |
| 246 | 246 |
| 247 LocatedEvent::LocatedEvent(const LocatedEvent& model) |
| 248 : Event(model), |
| 249 location_(model.location_), |
| 250 root_location_(model.root_location_), |
| 251 valid_system_location_(model.valid_system_location_), |
| 252 system_location_(model.system_location_) { |
| 253 } |
| 254 |
| 247 LocatedEvent::LocatedEvent(EventType type, | 255 LocatedEvent::LocatedEvent(EventType type, |
| 248 const gfx::Point& location, | 256 const gfx::Point& location, |
| 249 const gfx::Point& root_location, | 257 const gfx::Point& root_location, |
| 250 base::TimeDelta time_stamp, | 258 base::TimeDelta time_stamp, |
| 251 int flags) | 259 int flags) |
| 252 : Event(type, time_stamp, flags), | 260 : Event(type, time_stamp, flags), |
| 253 location_(location), | 261 location_(location), |
| 254 root_location_(root_location), | 262 root_location_(root_location), |
| 255 valid_system_location_(false), | 263 valid_system_location_(false), |
| 256 system_location_(0, 0) { | 264 system_location_(0, 0) { |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 bool is_cancel; | 641 bool is_cancel; |
| 634 GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel); | 642 GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel); |
| 635 } else { | 643 } else { |
| 636 NOTREACHED() << "Unexpected event type " << type() | 644 NOTREACHED() << "Unexpected event type " << type() |
| 637 << " when constructing a ScrollEvent."; | 645 << " when constructing a ScrollEvent."; |
| 638 } | 646 } |
| 639 } | 647 } |
| 640 | 648 |
| 641 ScrollEvent::ScrollEvent(EventType type, | 649 ScrollEvent::ScrollEvent(EventType type, |
| 642 const gfx::Point& location, | 650 const gfx::Point& location, |
| 651 base::TimeDelta time_stamp, |
| 643 int flags, | 652 int flags, |
| 644 float x_offset, | 653 float x_offset, |
| 645 float y_offset) | 654 float y_offset, |
| 655 int finger_count) |
| 646 : MouseEvent(type, location, location, flags), | 656 : MouseEvent(type, location, location, flags), |
| 647 x_offset_(x_offset), | 657 x_offset_(x_offset), |
| 648 y_offset_(y_offset) { | 658 y_offset_(y_offset), |
| 659 finger_count_(finger_count) { |
| 660 set_time_stamp(time_stamp); |
| 649 CHECK(IsScrollEvent()); | 661 CHECK(IsScrollEvent()); |
| 650 } | 662 } |
| 651 | 663 |
| 652 void ScrollEvent::Scale(const float factor) { | 664 void ScrollEvent::Scale(const float factor) { |
| 653 x_offset_ *= factor; | 665 x_offset_ *= factor; |
| 654 y_offset_ *= factor; | 666 y_offset_ *= factor; |
| 655 } | 667 } |
| 656 | 668 |
| 657 //////////////////////////////////////////////////////////////////////////////// | 669 //////////////////////////////////////////////////////////////////////////////// |
| 658 // GestureEvent | 670 // GestureEvent |
| 659 | 671 |
| 660 GestureEvent::GestureEvent(EventType type, | 672 GestureEvent::GestureEvent(EventType type, |
| 661 int x, | 673 int x, |
| 662 int y, | 674 int y, |
| 663 int flags, | 675 int flags, |
| 664 base::TimeDelta time_stamp, | 676 base::TimeDelta time_stamp, |
| 665 const GestureEventDetails& details, | 677 const GestureEventDetails& details, |
| 666 unsigned int touch_ids_bitfield) | 678 unsigned int touch_ids_bitfield) |
| 667 : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), time_stamp, flags), | 679 : LocatedEvent(type, |
| 680 gfx::Point(x, y), |
| 681 gfx::Point(x, y), |
| 682 time_stamp, |
| 683 flags | EF_FROM_TOUCH), |
| 668 details_(details), | 684 details_(details), |
| 669 touch_ids_bitfield_(touch_ids_bitfield) { | 685 touch_ids_bitfield_(touch_ids_bitfield) { |
| 670 } | 686 } |
| 671 | 687 |
| 672 GestureEvent::~GestureEvent() { | 688 GestureEvent::~GestureEvent() { |
| 673 } | 689 } |
| 674 | 690 |
| 675 int GestureEvent::GetLowestTouchId() const { | 691 int GestureEvent::GetLowestTouchId() const { |
| 676 if (touch_ids_bitfield_ == 0) | 692 if (touch_ids_bitfield_ == 0) |
| 677 return -1; | 693 return -1; |
| 678 int i = -1; | 694 int i = -1; |
| 679 // Find the index of the least significant 1 bit | 695 // Find the index of the least significant 1 bit |
| 680 while (!(1 << ++i & touch_ids_bitfield_)); | 696 while (!(1 << ++i & touch_ids_bitfield_)); |
| 681 return i; | 697 return i; |
| 682 } | 698 } |
| 683 | 699 |
| 684 } // namespace ui | 700 } // namespace ui |
| OLD | NEW |