| 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 "ash/touch/touch_uma.h" | 5 #include "ash/touch/touch_uma.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/aura/window_property.h" | 14 #include "ui/aura/window_property.h" |
| 15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 16 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
| 17 #include "ui/gfx/point_conversions.h" | 17 #include "ui/gfx/point_conversions.h" |
| 18 | 18 |
| 19 #if defined(USE_XI2_MT) | 19 #if defined(USE_X11) |
| 20 #include <X11/extensions/XInput2.h> | 20 #include <X11/extensions/XInput2.h> |
| 21 #include <X11/Xlib.h> | 21 #include <X11/Xlib.h> |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 struct WindowTouchDetails { | 26 struct WindowTouchDetails { |
| 27 // Move and start times of the touch points. The key is the touch-id. | 27 // Move and start times of the touch points. The key is the touch-id. |
| 28 std::map<int, base::TimeDelta> last_move_time_; | 28 std::map<int, base::TimeDelta> last_move_time_; |
| 29 std::map<int, base::TimeDelta> last_start_time_; | 29 std::map<int, base::TimeDelta> last_start_time_; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 const gfx::Rect bounds = target->GetRootWindow()->bounds(); | 96 const gfx::Rect bounds = target->GetRootWindow()->bounds(); |
| 97 const int bucket_size_x = std::max(1, | 97 const int bucket_size_x = std::max(1, |
| 98 bounds.width() / kBucketCountForLocation); | 98 bounds.width() / kBucketCountForLocation); |
| 99 const int bucket_size_y = std::max(1, | 99 const int bucket_size_y = std::max(1, |
| 100 bounds.height() / kBucketCountForLocation); | 100 bounds.height() / kBucketCountForLocation); |
| 101 | 101 |
| 102 gfx::Point position = event.root_location(); | 102 gfx::Point position = event.root_location(); |
| 103 | 103 |
| 104 // Prefer raw event location (when available) over calibrated location. | 104 // Prefer raw event location (when available) over calibrated location. |
| 105 if (event.HasNativeEvent()) { | 105 if (event.HasNativeEvent()) { |
| 106 #if defined(USE_XI2_MT) | 106 #if defined(USE_X11) |
| 107 XEvent* xevent = event.native_event(); | 107 XEvent* xevent = event.native_event(); |
| 108 CHECK_EQ(GenericEvent, xevent->type); | 108 CHECK_EQ(GenericEvent, xevent->type); |
| 109 XIEvent* xievent = static_cast<XIEvent*>(xevent->xcookie.data); | 109 XIEvent* xievent = static_cast<XIEvent*>(xevent->xcookie.data); |
| 110 if (xievent->evtype == XI_TouchBegin || | 110 if (xievent->evtype == XI_TouchBegin || |
| 111 xievent->evtype == XI_TouchUpdate || | 111 xievent->evtype == XI_TouchUpdate || |
| 112 xievent->evtype == XI_TouchEnd) { | 112 xievent->evtype == XI_TouchEnd) { |
| 113 XIDeviceEvent* device_event = | 113 XIDeviceEvent* device_event = |
| 114 static_cast<XIDeviceEvent*>(xevent->xcookie.data); | 114 static_cast<XIDeviceEvent*>(xevent->xcookie.data); |
| 115 position.SetPoint(static_cast<int>(device_event->event_x), | 115 position.SetPoint(static_cast<int>(device_event->event_x), |
| 116 static_cast<int>(device_event->event_y)); | 116 static_cast<int>(device_event->event_y)); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 return GESTURE_OMNIBOX_SCROLL; | 303 return GESTURE_OMNIBOX_SCROLL; |
| 304 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) | 304 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) |
| 305 return GESTURE_OMNIBOX_PINCH; | 305 return GESTURE_OMNIBOX_PINCH; |
| 306 return GESTURE_UNKNOWN; | 306 return GESTURE_UNKNOWN; |
| 307 } | 307 } |
| 308 | 308 |
| 309 return GESTURE_UNKNOWN; | 309 return GESTURE_UNKNOWN; |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace ash | 312 } // namespace ash |
| OLD | NEW |