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/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 return event; | 37 return event; |
38 #elif defined(USE_OZONE) | 38 #elif defined(USE_OZONE) |
39 return NULL; | 39 return NULL; |
40 #else | 40 #else |
41 NOTREACHED() << | 41 NOTREACHED() << |
42 "Don't know how to copy base::NativeEvent for this platform"; | 42 "Don't know how to copy base::NativeEvent for this platform"; |
43 return NULL; | 43 return NULL; |
44 #endif | 44 #endif |
45 } | 45 } |
46 | 46 |
47 gfx::Point CalibratePoint(const gfx::Point& point, | |
48 const gfx::Size& from, | |
49 const gfx::Size& to) { | |
50 float calibrated_x = | |
51 static_cast<float>(point.x()) * to.width() / from.width(); | |
52 float calibrated_y = | |
53 static_cast<float>(point.y()) * to.height() / from.height(); | |
54 return gfx::Point(static_cast<int>(floorf(calibrated_x + 0.5f)), | |
55 static_cast<int>(floorf(calibrated_y + 0.5f))); | |
56 } | |
57 | |
58 std::string EventTypeName(ui::EventType type) { | 47 std::string EventTypeName(ui::EventType type) { |
59 #define RETURN_IF_TYPE(t) if (type == ui::t) return #t | 48 #define RETURN_IF_TYPE(t) if (type == ui::t) return #t |
60 #define CASE_TYPE(t) case ui::t: return #t | 49 #define CASE_TYPE(t) case ui::t: return #t |
61 switch (type) { | 50 switch (type) { |
62 CASE_TYPE(ET_UNKNOWN); | 51 CASE_TYPE(ET_UNKNOWN); |
63 CASE_TYPE(ET_MOUSE_PRESSED); | 52 CASE_TYPE(ET_MOUSE_PRESSED); |
64 CASE_TYPE(ET_MOUSE_DRAGGED); | 53 CASE_TYPE(ET_MOUSE_DRAGGED); |
65 CASE_TYPE(ET_MOUSE_RELEASED); | 54 CASE_TYPE(ET_MOUSE_RELEASED); |
66 CASE_TYPE(ET_MOUSE_MOVED); | 55 CASE_TYPE(ET_MOUSE_MOVED); |
67 CASE_TYPE(ET_MOUSE_ENTERED); | 56 CASE_TYPE(ET_MOUSE_ENTERED); |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 int GestureEvent::GetLowestTouchId() const { | 708 int GestureEvent::GetLowestTouchId() const { |
720 if (touch_ids_bitfield_ == 0) | 709 if (touch_ids_bitfield_ == 0) |
721 return -1; | 710 return -1; |
722 int i = -1; | 711 int i = -1; |
723 // Find the index of the least significant 1 bit | 712 // Find the index of the least significant 1 bit |
724 while (!(1 << ++i & touch_ids_bitfield_)); | 713 while (!(1 << ++i & touch_ids_bitfield_)); |
725 return i; | 714 return i; |
726 } | 715 } |
727 | 716 |
728 } // namespace ui | 717 } // namespace ui |
OLD | NEW |