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/event.h" | 5 #include "ui/base/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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 f &= ~EF_IS_DOUBLE_CLICK; | 220 f &= ~EF_IS_DOUBLE_CLICK; |
221 f |= EF_IS_TRIPLE_CLICK; | 221 f |= EF_IS_TRIPLE_CLICK; |
222 break; | 222 break; |
223 } | 223 } |
224 set_flags(f); | 224 set_flags(f); |
225 } | 225 } |
226 | 226 |
227 MouseEvent::MouseEvent(const MouseEvent& model) : LocatedEvent(model) { | 227 MouseEvent::MouseEvent(const MouseEvent& model) : LocatedEvent(model) { |
228 } | 228 } |
229 | 229 |
| 230 MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event) |
| 231 #if defined(USE_AURA) |
| 232 : MouseEvent(static_cast<const MouseEvent&>(*native_event)), |
| 233 offset_(GetMouseWheelOffset(native_event->native_event())) { |
| 234 #else |
| 235 : MouseEvent(native_event), |
| 236 offset_(GetMouseWheelOffset(native_event)) { |
| 237 #endif |
| 238 } |
| 239 |
| 240 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) |
| 241 : MouseEvent(scroll_event), |
| 242 offset_(scroll_event.y_offset()) { |
| 243 set_type(ET_MOUSEWHEEL); |
| 244 } |
| 245 |
| 246 #if defined(OS_WIN) |
| 247 // This value matches windows WHEEL_DELTA. |
| 248 // static |
| 249 const int MouseWheelEvent::kWheelDelta = 120; |
| 250 #else |
| 251 // This value matches GTK+ wheel scroll amount. |
| 252 const int MouseWheelEvent::kWheelDelta = 53; |
| 253 #endif |
| 254 |
230 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | 255 TouchEvent::TouchEvent(const base::NativeEvent& native_event) |
231 : LocatedEvent(native_event), | 256 : LocatedEvent(native_event), |
232 touch_id_(ui::GetTouchId(native_event)), | 257 touch_id_(GetTouchId(native_event)), |
233 radius_x_(GetTouchRadiusX(native_event)), | 258 radius_x_(GetTouchRadiusX(native_event)), |
234 radius_y_(GetTouchRadiusY(native_event)), | 259 radius_y_(GetTouchRadiusY(native_event)), |
235 rotation_angle_(GetTouchAngle(native_event)), | 260 rotation_angle_(GetTouchAngle(native_event)), |
236 force_(GetTouchForce(native_event)) { | 261 force_(GetTouchForce(native_event)) { |
237 } | 262 } |
238 | 263 |
239 TouchEvent::TouchEvent(EventType type, | 264 TouchEvent::TouchEvent(EventType type, |
240 const gfx::Point& location, | 265 const gfx::Point& location, |
241 int touch_id, | 266 int touch_id, |
242 base::TimeDelta time_stamp) | 267 base::TimeDelta time_stamp) |
243 : LocatedEvent(type, location, location, 0), | 268 : LocatedEvent(type, location, location, 0), |
244 touch_id_(touch_id), | 269 touch_id_(touch_id), |
245 radius_x_(0.0f), | 270 radius_x_(0.0f), |
246 radius_y_(0.0f), | 271 radius_y_(0.0f), |
247 rotation_angle_(0.0f), | 272 rotation_angle_(0.0f), |
248 force_(0.0f) { | 273 force_(0.0f) { |
249 set_time_stamp(time_stamp); | 274 set_time_stamp(time_stamp); |
250 } | 275 } |
251 | 276 |
252 TouchEvent::~TouchEvent() { | 277 TouchEvent::~TouchEvent() { |
253 } | 278 } |
254 | 279 |
255 void TouchEvent::UpdateForRootTransform(const Transform& root_transform) { | 280 void TouchEvent::UpdateForRootTransform(const Transform& root_transform) { |
256 LocatedEvent::UpdateForRootTransform(root_transform); | 281 LocatedEvent::UpdateForRootTransform(root_transform); |
257 gfx::Point3f scale; | 282 gfx::Point3f scale; |
258 InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); | 283 InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); |
259 if (scale.x()) | 284 if (scale.x()) |
260 radius_x_ /= scale.x(); | 285 radius_x_ /= scale.x(); |
261 if (scale.y()) | 286 if (scale.y()) |
262 radius_y_ /= scale.y(); | 287 radius_y_ /= scale.y(); |
263 } | 288 } |
264 | 289 |
| 290 TestTouchEvent::TestTouchEvent(EventType type, |
| 291 int x, |
| 292 int y, |
| 293 int flags, |
| 294 int touch_id, |
| 295 float radius_x, |
| 296 float radius_y, |
| 297 float angle, |
| 298 float force) |
| 299 : TouchEvent(type, gfx::Point(x, y), touch_id, base::TimeDelta()) { |
| 300 set_flags(flags); |
| 301 set_radius(radius_x, radius_y); |
| 302 set_rotation_angle(angle); |
| 303 set_force(force); |
| 304 } |
| 305 |
265 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) | 306 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) |
266 : Event(native_event, | 307 : Event(native_event, |
267 EventTypeFromNative(native_event), | 308 EventTypeFromNative(native_event), |
268 EventFlagsFromNative(native_event)), | 309 EventFlagsFromNative(native_event)), |
269 key_code_(KeyboardCodeFromNative(native_event)), | 310 key_code_(KeyboardCodeFromNative(native_event)), |
270 is_char_(is_char), | 311 is_char_(is_char), |
271 character_(0), | 312 character_(0), |
272 unmodified_character_(0) { | 313 unmodified_character_(0) { |
273 } | 314 } |
274 | 315 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 int GestureEvent::GetLowestTouchId() const { | 436 int GestureEvent::GetLowestTouchId() const { |
396 if (touch_ids_bitfield_ == 0) | 437 if (touch_ids_bitfield_ == 0) |
397 return -1; | 438 return -1; |
398 int i = -1; | 439 int i = -1; |
399 // Find the index of the least significant 1 bit | 440 // Find the index of the least significant 1 bit |
400 while (!(1 << ++i & touch_ids_bitfield_)); | 441 while (!(1 << ++i & touch_ids_bitfield_)); |
401 return i; | 442 return i; |
402 } | 443 } |
403 | 444 |
404 } // namespace ui | 445 } // namespace ui |
OLD | NEW |