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/events/event.h" | 5 #include "ui/events/event.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #endif | 10 #endif |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 Event::Event(EventType type, base::TimeDelta time_stamp, int flags) | 129 Event::Event(EventType type, base::TimeDelta time_stamp, int flags) |
130 : type_(type), | 130 : type_(type), |
131 time_stamp_(time_stamp), | 131 time_stamp_(time_stamp), |
132 flags_(flags), | 132 flags_(flags), |
133 native_event_(base::NativeEvent()), | 133 native_event_(base::NativeEvent()), |
134 delete_native_event_(false), | 134 delete_native_event_(false), |
135 cancelable_(true), | 135 cancelable_(true), |
136 target_(NULL), | 136 target_(NULL), |
137 phase_(EP_PREDISPATCH), | 137 phase_(EP_PREDISPATCH), |
138 result_(ER_UNHANDLED) { | 138 result_(ER_UNHANDLED) { |
| 139 #if defined(USE_OZONE) |
| 140 window_ = 0; |
| 141 #endif |
139 if (type_ < ET_LAST) | 142 if (type_ < ET_LAST) |
140 name_ = EventTypeName(type_); | 143 name_ = EventTypeName(type_); |
141 } | 144 } |
142 | 145 |
143 Event::Event(const base::NativeEvent& native_event, | 146 Event::Event(const base::NativeEvent& native_event, |
144 EventType type, | 147 EventType type, |
145 int flags) | 148 int flags) |
146 : type_(type), | 149 : type_(type), |
147 time_stamp_(EventTimeFromNative(native_event)), | 150 time_stamp_(EventTimeFromNative(native_event)), |
148 flags_(flags), | 151 flags_(flags), |
149 native_event_(native_event), | 152 native_event_(native_event), |
150 delete_native_event_(false), | 153 delete_native_event_(false), |
151 cancelable_(true), | 154 cancelable_(true), |
152 target_(NULL), | 155 target_(NULL), |
153 phase_(EP_PREDISPATCH), | 156 phase_(EP_PREDISPATCH), |
154 result_(ER_UNHANDLED) { | 157 result_(ER_UNHANDLED) { |
| 158 #if defined(USE_OZONE) |
| 159 window_ = 0; |
| 160 #endif |
| 161 |
155 base::TimeDelta delta = EventTimeForNow() - time_stamp_; | 162 base::TimeDelta delta = EventTimeForNow() - time_stamp_; |
156 if (type_ < ET_LAST) | 163 if (type_ < ET_LAST) |
157 name_ = EventTypeName(type_); | 164 name_ = EventTypeName(type_); |
158 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", | 165 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", |
159 delta.InMicroseconds(), 1, 1000000, 100); | 166 delta.InMicroseconds(), 1, 1000000, 100); |
160 std::string name_for_event = | 167 std::string name_for_event = |
161 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); | 168 base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); |
162 base::HistogramBase* counter_for_type = | 169 base::HistogramBase* counter_for_type = |
163 base::Histogram::FactoryGet( | 170 base::Histogram::FactoryGet( |
164 name_for_event, | 171 name_for_event, |
165 1, | 172 1, |
166 1000000, | 173 1000000, |
167 100, | 174 100, |
168 base::HistogramBase::kUmaTargetedHistogramFlag); | 175 base::HistogramBase::kUmaTargetedHistogramFlag); |
169 counter_for_type->Add(delta.InMicroseconds()); | 176 counter_for_type->Add(delta.InMicroseconds()); |
170 } | 177 } |
171 | 178 |
172 Event::Event(const Event& copy) | 179 Event::Event(const Event& copy) |
173 : type_(copy.type_), | 180 : type_(copy.type_), |
174 time_stamp_(copy.time_stamp_), | 181 time_stamp_(copy.time_stamp_), |
175 latency_(copy.latency_), | 182 latency_(copy.latency_), |
176 flags_(copy.flags_), | 183 flags_(copy.flags_), |
177 native_event_(CopyNativeEvent(copy.native_event_)), | 184 native_event_(CopyNativeEvent(copy.native_event_)), |
178 delete_native_event_(true), | 185 delete_native_event_(true), |
179 cancelable_(true), | 186 cancelable_(true), |
180 target_(NULL), | 187 target_(NULL), |
181 phase_(EP_PREDISPATCH), | 188 phase_(EP_PREDISPATCH), |
182 result_(ER_UNHANDLED) { | 189 result_(ER_UNHANDLED) { |
| 190 #if defined(USE_OZONE) |
| 191 window_ = 0; |
| 192 #endif |
| 193 |
183 if (type_ < ET_LAST) | 194 if (type_ < ET_LAST) |
184 name_ = EventTypeName(type_); | 195 name_ = EventTypeName(type_); |
185 } | 196 } |
186 | 197 |
187 void Event::SetType(EventType type) { | 198 void Event::SetType(EventType type) { |
188 if (type_ < ET_LAST) | 199 if (type_ < ET_LAST) |
189 name_ = std::string(); | 200 name_ = std::string(); |
190 type_ = type; | 201 type_ = type; |
191 if (type_ < ET_LAST) | 202 if (type_ < ET_LAST) |
192 name_ = EventTypeName(type_); | 203 name_ = EventTypeName(type_); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 int GestureEvent::GetLowestTouchId() const { | 706 int GestureEvent::GetLowestTouchId() const { |
696 if (touch_ids_bitfield_ == 0) | 707 if (touch_ids_bitfield_ == 0) |
697 return -1; | 708 return -1; |
698 int i = -1; | 709 int i = -1; |
699 // Find the index of the least significant 1 bit | 710 // Find the index of the least significant 1 bit |
700 while (!(1 << ++i & touch_ids_bitfield_)); | 711 while (!(1 << ++i & touch_ids_bitfield_)); |
701 return i; | 712 return i; |
702 } | 713 } |
703 | 714 |
704 } // namespace ui | 715 } // namespace ui |
OLD | NEW |