| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 455 } |
| 456 | 456 |
| 457 TouchEvent::~TouchEvent() { | 457 TouchEvent::~TouchEvent() { |
| 458 } | 458 } |
| 459 | 459 |
| 460 void TouchEvent::Relocate(const gfx::Point& origin) { | 460 void TouchEvent::Relocate(const gfx::Point& origin) { |
| 461 location_ -= origin.OffsetFromOrigin(); | 461 location_ -= origin.OffsetFromOrigin(); |
| 462 root_location_ -= origin.OffsetFromOrigin(); | 462 root_location_ -= origin.OffsetFromOrigin(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { | 465 void TouchEvent::UpdateForRootTransform( |
| 466 LocatedEvent::UpdateForRootTransform(root_transform); | 466 const gfx::Transform& inverted_root_transform) { |
| 467 LocatedEvent::UpdateForRootTransform(inverted_root_transform); |
| 467 gfx::DecomposedTransform decomp; | 468 gfx::DecomposedTransform decomp; |
| 468 bool success = gfx::DecomposeTransform(&decomp, root_transform); | 469 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); |
| 469 DCHECK(success); | 470 DCHECK(success); |
| 470 if (decomp.scale[0]) | 471 if (decomp.scale[0]) |
| 471 radius_x_ /= decomp.scale[0]; | 472 radius_x_ *= decomp.scale[0]; |
| 472 if (decomp.scale[1]) | 473 if (decomp.scale[1]) |
| 473 radius_y_ /= decomp.scale[1]; | 474 radius_y_ *= decomp.scale[1]; |
| 474 } | 475 } |
| 475 | 476 |
| 476 //////////////////////////////////////////////////////////////////////////////// | 477 //////////////////////////////////////////////////////////////////////////////// |
| 477 // KeyEvent | 478 // KeyEvent |
| 478 | 479 |
| 479 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) | 480 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) |
| 480 : Event(native_event, | 481 : Event(native_event, |
| 481 EventTypeFromNative(native_event), | 482 EventTypeFromNative(native_event), |
| 482 EventFlagsFromNative(native_event)), | 483 EventFlagsFromNative(native_event)), |
| 483 key_code_(KeyboardCodeFromNative(native_event)), | 484 key_code_(KeyboardCodeFromNative(native_event)), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 CHECK(IsScrollEvent()); | 684 CHECK(IsScrollEvent()); |
| 684 } | 685 } |
| 685 | 686 |
| 686 void ScrollEvent::Scale(const float factor) { | 687 void ScrollEvent::Scale(const float factor) { |
| 687 x_offset_ *= factor; | 688 x_offset_ *= factor; |
| 688 y_offset_ *= factor; | 689 y_offset_ *= factor; |
| 689 x_offset_ordinal_ *= factor; | 690 x_offset_ordinal_ *= factor; |
| 690 y_offset_ordinal_ *= factor; | 691 y_offset_ordinal_ *= factor; |
| 691 } | 692 } |
| 692 | 693 |
| 693 void ScrollEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { | 694 void ScrollEvent::UpdateForRootTransform( |
| 694 LocatedEvent::UpdateForRootTransform(root_transform); | 695 const gfx::Transform& inverted_root_transform) { |
| 696 LocatedEvent::UpdateForRootTransform(inverted_root_transform); |
| 695 gfx::DecomposedTransform decomp; | 697 gfx::DecomposedTransform decomp; |
| 696 bool success = gfx::DecomposeTransform(&decomp, root_transform); | 698 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); |
| 697 DCHECK(success); | 699 DCHECK(success); |
| 698 if (decomp.scale[0]) | 700 if (decomp.scale[0]) |
| 699 x_offset_ordinal_ /= decomp.scale[0]; | 701 x_offset_ordinal_ *= decomp.scale[0]; |
| 700 if (decomp.scale[1]) | 702 if (decomp.scale[1]) |
| 701 y_offset_ordinal_ /= decomp.scale[1]; | 703 y_offset_ordinal_ *= decomp.scale[1]; |
| 702 } | 704 } |
| 703 | 705 |
| 704 //////////////////////////////////////////////////////////////////////////////// | 706 //////////////////////////////////////////////////////////////////////////////// |
| 705 // GestureEvent | 707 // GestureEvent |
| 706 | 708 |
| 707 GestureEvent::GestureEvent(EventType type, | 709 GestureEvent::GestureEvent(EventType type, |
| 708 int x, | 710 int x, |
| 709 int y, | 711 int y, |
| 710 int flags, | 712 int flags, |
| 711 base::TimeDelta time_stamp, | 713 base::TimeDelta time_stamp, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 726 int GestureEvent::GetLowestTouchId() const { | 728 int GestureEvent::GetLowestTouchId() const { |
| 727 if (touch_ids_bitfield_ == 0) | 729 if (touch_ids_bitfield_ == 0) |
| 728 return -1; | 730 return -1; |
| 729 int i = -1; | 731 int i = -1; |
| 730 // Find the index of the least significant 1 bit | 732 // Find the index of the least significant 1 bit |
| 731 while (!(1 << ++i & touch_ids_bitfield_)); | 733 while (!(1 << ++i & touch_ids_bitfield_)); |
| 732 return i; | 734 return i; |
| 733 } | 735 } |
| 734 | 736 |
| 735 } // namespace ui | 737 } // namespace ui |
| OLD | NEW |