| 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/shell_delegate.h" | 7 #include "ash/shell_delegate.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_property.h" | 12 #include "ui/aura/window_property.h" |
| 13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
| 14 #include "ui/gfx/point_conversions.h" |
| 14 | 15 |
| 15 #if defined(USE_XI2_MT) | 16 #if defined(USE_XI2_MT) |
| 16 #include <X11/extensions/XInput2.h> | 17 #include <X11/extensions/XInput2.h> |
| 17 #include <X11/Xlib.h> | 18 #include <X11/Xlib.h> |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 enum GestureActionType { | 23 enum GestureActionType { |
| 23 GESTURE_UNKNOWN, | 24 GESTURE_UNKNOWN, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 XIDeviceEvent* device_event = | 306 XIDeviceEvent* device_event = |
| 306 static_cast<XIDeviceEvent*>(xevent->xcookie.data); | 307 static_cast<XIDeviceEvent*>(xevent->xcookie.data); |
| 307 position.SetPoint(static_cast<int>(device_event->event_x), | 308 position.SetPoint(static_cast<int>(device_event->event_x), |
| 308 static_cast<int>(device_event->event_y)); | 309 static_cast<int>(device_event->event_y)); |
| 309 } else { | 310 } else { |
| 310 position = ui::EventLocationFromNative(event.native_event()); | 311 position = ui::EventLocationFromNative(event.native_event()); |
| 311 } | 312 } |
| 312 #else | 313 #else |
| 313 position = ui::EventLocationFromNative(event.native_event()); | 314 position = ui::EventLocationFromNative(event.native_event()); |
| 314 #endif | 315 #endif |
| 315 position = position.Scale(1. / target->layer()->device_scale_factor()); | 316 position = gfx::ToFlooredPoint( |
| 317 position.Scale(1. / target->layer()->device_scale_factor())); |
| 316 } | 318 } |
| 317 | 319 |
| 318 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); | 320 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); |
| 319 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); | 321 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); |
| 320 | 322 |
| 321 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionX", | 323 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionX", |
| 322 position.x() / bucket_size_x, | 324 position.x() / bucket_size_x, |
| 323 0, kBucketCountForLocation, kBucketCountForLocation + 1); | 325 0, kBucketCountForLocation, kBucketCountForLocation + 1); |
| 324 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", | 326 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", |
| 325 position.y() / bucket_size_y, | 327 position.y() / bucket_size_y, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 379 |
| 378 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); | 380 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); |
| 379 | 381 |
| 380 details->last_move_time_[event.touch_id()] = event.time_stamp(); | 382 details->last_move_time_[event.touch_id()] = event.time_stamp(); |
| 381 details->last_touch_position_[event.touch_id()] = event.location(); | 383 details->last_touch_position_[event.touch_id()] = event.location(); |
| 382 } | 384 } |
| 383 } | 385 } |
| 384 | 386 |
| 385 } // namespace internal | 387 } // namespace internal |
| 386 } // namespace ash | 388 } // namespace ash |
| OLD | NEW |