| 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 data_(data), | 618 data_(data), |
| 619 source_operations_(source_operations) { | 619 source_operations_(source_operations) { |
| 620 } | 620 } |
| 621 | 621 |
| 622 //////////////////////////////////////////////////////////////////////////////// | 622 //////////////////////////////////////////////////////////////////////////////// |
| 623 // ScrollEvent | 623 // ScrollEvent |
| 624 | 624 |
| 625 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) | 625 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) |
| 626 : MouseEvent(native_event) { | 626 : MouseEvent(native_event) { |
| 627 if (type() == ET_SCROLL) { | 627 if (type() == ET_SCROLL) { |
| 628 GetScrollOffsets(native_event, &x_offset_, &y_offset_, &finger_count_); | 628 GetScrollOffsets(native_event, |
| 629 double start, end; | 629 &x_offset_, &y_offset_, |
| 630 GetGestureTimes(native_event, &start, &end); | 630 &x_offset_ordinal_, &y_offset_ordinal_, |
| 631 &finger_count_); |
| 631 } else if (type() == ET_SCROLL_FLING_START || | 632 } else if (type() == ET_SCROLL_FLING_START || |
| 632 type() == ET_SCROLL_FLING_CANCEL) { | 633 type() == ET_SCROLL_FLING_CANCEL) { |
| 633 bool is_cancel; | 634 GetFlingData(native_event, |
| 634 GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel); | 635 &x_offset_, &y_offset_, |
| 636 &x_offset_ordinal_, &y_offset_ordinal_, |
| 637 NULL); |
| 635 } else { | 638 } else { |
| 636 NOTREACHED() << "Unexpected event type " << type() | 639 NOTREACHED() << "Unexpected event type " << type() |
| 637 << " when constructing a ScrollEvent."; | 640 << " when constructing a ScrollEvent."; |
| 638 } | 641 } |
| 639 } | 642 } |
| 640 | 643 |
| 641 ScrollEvent::ScrollEvent(EventType type, | 644 ScrollEvent::ScrollEvent(EventType type, |
| 642 const gfx::Point& location, | 645 const gfx::Point& location, |
| 643 base::TimeDelta time_stamp, | 646 base::TimeDelta time_stamp, |
| 644 int flags, | 647 int flags, |
| 645 float x_offset, | 648 float x_offset, |
| 646 float y_offset, | 649 float y_offset, |
| 650 float x_offset_ordinal, |
| 651 float y_offset_ordinal, |
| 647 int finger_count) | 652 int finger_count) |
| 648 : MouseEvent(type, location, location, flags), | 653 : MouseEvent(type, location, location, flags), |
| 649 x_offset_(x_offset), | 654 x_offset_(x_offset), |
| 650 y_offset_(y_offset), | 655 y_offset_(y_offset), |
| 656 x_offset_ordinal_(x_offset_ordinal), |
| 657 y_offset_ordinal_(y_offset_ordinal), |
| 651 finger_count_(finger_count) { | 658 finger_count_(finger_count) { |
| 652 set_time_stamp(time_stamp); | 659 set_time_stamp(time_stamp); |
| 653 CHECK(IsScrollEvent()); | 660 CHECK(IsScrollEvent()); |
| 654 } | 661 } |
| 655 | 662 |
| 656 void ScrollEvent::Scale(const float factor) { | 663 void ScrollEvent::Scale(const float factor) { |
| 657 x_offset_ *= factor; | 664 x_offset_ *= factor; |
| 658 y_offset_ *= factor; | 665 y_offset_ *= factor; |
| 666 x_offset_ordinal_ *= factor; |
| 667 y_offset_ordinal_ *= factor; |
| 659 } | 668 } |
| 660 | 669 |
| 661 //////////////////////////////////////////////////////////////////////////////// | 670 //////////////////////////////////////////////////////////////////////////////// |
| 662 // GestureEvent | 671 // GestureEvent |
| 663 | 672 |
| 664 GestureEvent::GestureEvent(EventType type, | 673 GestureEvent::GestureEvent(EventType type, |
| 665 int x, | 674 int x, |
| 666 int y, | 675 int y, |
| 667 int flags, | 676 int flags, |
| 668 base::TimeDelta time_stamp, | 677 base::TimeDelta time_stamp, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 683 int GestureEvent::GetLowestTouchId() const { | 692 int GestureEvent::GetLowestTouchId() const { |
| 684 if (touch_ids_bitfield_ == 0) | 693 if (touch_ids_bitfield_ == 0) |
| 685 return -1; | 694 return -1; |
| 686 int i = -1; | 695 int i = -1; |
| 687 // Find the index of the least significant 1 bit | 696 // Find the index of the least significant 1 bit |
| 688 while (!(1 << ++i & touch_ids_bitfield_)); | 697 while (!(1 << ++i & touch_ids_bitfield_)); |
| 689 return i; | 698 return i; |
| 690 } | 699 } |
| 691 | 700 |
| 692 } // namespace ui | 701 } // namespace ui |
| OLD | NEW |