Chromium Code Reviews| 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/aura/event.h" | 5 #include "ui/aura/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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 93 } |
| 94 | 94 |
| 95 LocatedEvent::~LocatedEvent() { | 95 LocatedEvent::~LocatedEvent() { |
| 96 } | 96 } |
| 97 | 97 |
| 98 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) | 98 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) |
| 99 : Event(native_event, | 99 : Event(native_event, |
| 100 ui::EventTypeFromNative(native_event), | 100 ui::EventTypeFromNative(native_event), |
| 101 ui::EventFlagsFromNative(native_event)), | 101 ui::EventFlagsFromNative(native_event)), |
| 102 location_(ui::EventLocationFromNative(native_event)), | 102 location_(ui::EventLocationFromNative(native_event)), |
| 103 root_location_(location_) { | 103 root_location_(ui::EventRootLocationFromNative(native_event)) { |
| 104 } | 104 } |
| 105 | 105 |
| 106 LocatedEvent::LocatedEvent(const LocatedEvent& model, | 106 LocatedEvent::LocatedEvent(const LocatedEvent& model, |
| 107 Window* source, | 107 Window* source, |
| 108 Window* target) | 108 Window* target) |
| 109 : Event(model), | 109 : Event(model), |
| 110 location_(model.location_), | 110 location_(model.location_), |
| 111 root_location_(model.root_location_) { | 111 root_location_(model.root_location_) { |
| 112 if (target && target != source) | 112 if (target && target != source) |
| 113 Window::ConvertPointToWindow(source, target, &location_); | 113 Window::ConvertPointToWindow(source, target, &location_); |
| 114 } | 114 } |
| 115 | 115 |
| 116 LocatedEvent::LocatedEvent(ui::EventType type, | 116 LocatedEvent::LocatedEvent(ui::EventType type, |
| 117 const gfx::Point& location, | 117 const gfx::Point& location, |
| 118 const gfx::Point& root_location, | 118 const gfx::Point& root_location, |
| 119 int flags) | 119 int flags) |
| 120 : Event(type, flags), | 120 : Event(type, flags), |
| 121 location_(location), | 121 location_(location), |
| 122 root_location_(location) { | 122 root_location_(location) { |
| 123 } | 123 } |
| 124 | 124 |
| 125 void LocatedEvent::UpdateForRootTransform(const ui::Transform& root_transform) { | 125 void LocatedEvent::UpdateForRootTransform(const ui::Transform& root_transform) { |
| 126 // Transform has to be done at root level. | 126 // Transform has to be done at root level. |
| 127 DCHECK_EQ(root_location_.x(), location_.x()); | 127 if (!root_transform.matrix().isIdentity()) { |
| 128 DCHECK_EQ(root_location_.y(), location_.y()); | 128 // TODO(oshima): This isn't correct with more than two RootWindows. |
|
Daniel Erat
2012/05/09 20:58:27
Not sure I understand this. Should it be "two or
| |
| 129 gfx::Point3f p(location_); | 129 DCHECK_EQ(root_location_.x(), location_.x()); |
| 130 root_transform.TransformPointReverse(p); | 130 DCHECK_EQ(root_location_.y(), location_.y()); |
| 131 root_location_ = location_ = p.AsPoint(); | 131 gfx::Point3f p(location_); |
| 132 root_transform.TransformPointReverse(p); | |
| 133 root_location_ = location_ = p.AsPoint(); | |
| 134 } | |
| 132 } | 135 } |
| 133 | 136 |
| 134 MouseEvent::MouseEvent(const base::NativeEvent& native_event) | 137 MouseEvent::MouseEvent(const base::NativeEvent& native_event) |
| 135 : LocatedEvent(native_event) { | 138 : LocatedEvent(native_event) { |
| 136 if (type() == ui::ET_MOUSE_PRESSED) | 139 if (type() == ui::ET_MOUSE_PRESSED) |
| 137 SetClickCount(GetRepeatCount(*this)); | 140 SetClickCount(GetRepeatCount(*this)); |
| 138 } | 141 } |
| 139 | 142 |
| 140 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target) | 143 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target) |
| 141 : LocatedEvent(model, source, target) { | 144 : LocatedEvent(model, source, target) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 int GestureEvent::GetLowestTouchId() const { | 466 int GestureEvent::GetLowestTouchId() const { |
| 464 if (touch_ids_bitfield_ == 0) | 467 if (touch_ids_bitfield_ == 0) |
| 465 return -1; | 468 return -1; |
| 466 int i = -1; | 469 int i = -1; |
| 467 // Find the index of the least significant 1 bit | 470 // Find the index of the least significant 1 bit |
| 468 while (!(1 << ++i & touch_ids_bitfield_)); | 471 while (!(1 << ++i & touch_ids_bitfield_)); |
| 469 return i; | 472 return i; |
| 470 } | 473 } |
| 471 | 474 |
| 472 } // namespace aura | 475 } // namespace aura |
| OLD | NEW |