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)) { |
sadrul
2012/05/10 13:34:10
This might be tricky; I think 'root_location_' is
| |
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 in any environment that isn't ash. It |
129 gfx::Point3f p(location_); | 129 // assumes that the all locations are root relative which is only true in |
130 root_transform.TransformPointReverse(p); | 130 // ash. This is only true in real desktop environments when our window is |
131 root_location_ = location_ = p.AsPoint(); | 131 // sitting at the root origin. |
132 DCHECK_EQ(root_location_.x(), location_.x()); | |
133 DCHECK_EQ(root_location_.y(), location_.y()); | |
134 gfx::Point3f p(location_); | |
135 root_transform.TransformPointReverse(p); | |
136 root_location_ = location_ = p.AsPoint(); | |
137 } | |
132 } | 138 } |
133 | 139 |
134 MouseEvent::MouseEvent(const base::NativeEvent& native_event) | 140 MouseEvent::MouseEvent(const base::NativeEvent& native_event) |
135 : LocatedEvent(native_event) { | 141 : LocatedEvent(native_event) { |
136 if (type() == ui::ET_MOUSE_PRESSED) | 142 if (type() == ui::ET_MOUSE_PRESSED) |
137 SetClickCount(GetRepeatCount(*this)); | 143 SetClickCount(GetRepeatCount(*this)); |
138 } | 144 } |
139 | 145 |
140 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target) | 146 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target) |
141 : LocatedEvent(model, source, target) { | 147 : LocatedEvent(model, source, target) { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 int GestureEvent::GetLowestTouchId() const { | 469 int GestureEvent::GetLowestTouchId() const { |
464 if (touch_ids_bitfield_ == 0) | 470 if (touch_ids_bitfield_ == 0) |
465 return -1; | 471 return -1; |
466 int i = -1; | 472 int i = -1; |
467 // Find the index of the least significant 1 bit | 473 // Find the index of the least significant 1 bit |
468 while (!(1 << ++i & touch_ids_bitfield_)); | 474 while (!(1 << ++i & touch_ids_bitfield_)); |
469 return i; | 475 return i; |
470 } | 476 } |
471 | 477 |
472 } // namespace aura | 478 } // namespace aura |
OLD | NEW |