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 |
11 #include <cmath> | 11 #include <cmath> |
12 #include <cstring> | 12 #include <cstring> |
13 | 13 |
14 #include "ui/base/events/event_utils.h" | 14 #include "ui/base/events/event_utils.h" |
15 #include "ui/base/keycodes/keyboard_code_conversion.h" | 15 #include "ui/base/keycodes/keyboard_code_conversion.h" |
16 #include "ui/gfx/interpolated_transform.h" | |
17 #include "ui/gfx/point3_f.h" | 16 #include "ui/gfx/point3_f.h" |
18 #include "ui/gfx/point_conversions.h" | 17 #include "ui/gfx/point_conversions.h" |
19 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
| 19 #include "ui/gfx/transform_util.h" |
20 | 20 |
21 #if defined(USE_X11) | 21 #if defined(USE_X11) |
22 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 22 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
23 #endif | 23 #endif |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { | 27 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { |
28 #if defined(USE_X11) | 28 #if defined(USE_X11) |
29 if (!event || event->type == GenericEvent) | 29 if (!event || event->type == GenericEvent) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 TouchEvent::~TouchEvent() { | 333 TouchEvent::~TouchEvent() { |
334 } | 334 } |
335 | 335 |
336 void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) { | 336 void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) { |
337 location_ = CalibratePoint(location_, from, to); | 337 location_ = CalibratePoint(location_, from, to); |
338 root_location_ = CalibratePoint(root_location_, from, to); | 338 root_location_ = CalibratePoint(root_location_, from, to); |
339 } | 339 } |
340 | 340 |
341 void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { | 341 void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) { |
342 LocatedEvent::UpdateForRootTransform(root_transform); | 342 LocatedEvent::UpdateForRootTransform(root_transform); |
343 gfx::Point3F scale; | 343 gfx::DecomposedTransform decomp; |
344 InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); | 344 bool success = gfx::DecomposeTransform(&decomp, root_transform); |
345 if (scale.x()) | 345 DCHECK(success); |
346 radius_x_ /= scale.x(); | 346 if (decomp.scale[0]) |
347 if (scale.y()) | 347 radius_x_ /= decomp.scale[0]; |
348 radius_y_ /= scale.y(); | 348 if (decomp.scale[1]) |
| 349 radius_y_ /= decomp.scale[1]; |
349 } | 350 } |
350 | 351 |
351 //////////////////////////////////////////////////////////////////////////////// | 352 //////////////////////////////////////////////////////////////////////////////// |
352 // KeyEvent | 353 // KeyEvent |
353 | 354 |
354 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) | 355 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) |
355 : Event(native_event, | 356 : Event(native_event, |
356 EventTypeFromNative(native_event), | 357 EventTypeFromNative(native_event), |
357 EventFlagsFromNative(native_event)), | 358 EventFlagsFromNative(native_event)), |
358 key_code_(KeyboardCodeFromNative(native_event)), | 359 key_code_(KeyboardCodeFromNative(native_event)), |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 int GestureEvent::GetLowestTouchId() const { | 546 int GestureEvent::GetLowestTouchId() const { |
546 if (touch_ids_bitfield_ == 0) | 547 if (touch_ids_bitfield_ == 0) |
547 return -1; | 548 return -1; |
548 int i = -1; | 549 int i = -1; |
549 // Find the index of the least significant 1 bit | 550 // Find the index of the least significant 1 bit |
550 while (!(1 << ++i & touch_ids_bitfield_)); | 551 while (!(1 << ++i & touch_ids_bitfield_)); |
551 return i; | 552 return i; |
552 } | 553 } |
553 | 554 |
554 } // namespace ui | 555 } // namespace ui |
OLD | NEW |