Commit bfb23cb9 authored by khmel@chromium.org's avatar khmel@chromium.org Committed by Commit Bot

exo: Add tracing for input events.

This traces input event and provide information that could be used to
match events on Android side.

TEST=Locally, confirmed that input events appear in ARC++ tracing tool.
BUG=b:132709527

Change-Id: Ice6e823f7be43db0e832253913c27a810dcca4cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625816
Commit-Queue: Yury Khmel <khmel@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664448}
parent 573ee01f
...@@ -25,6 +25,7 @@ source_set("exo") { ...@@ -25,6 +25,7 @@ source_set("exo") {
"display.h", "display.h",
"frame_sink_resource_manager.cc", "frame_sink_resource_manager.cc",
"frame_sink_resource_manager.h", "frame_sink_resource_manager.h",
"input_trace.h",
"keyboard_delegate.h", "keyboard_delegate.h",
"keyboard_device_configuration_delegate.h", "keyboard_device_configuration_delegate.h",
"keyboard_observer.h", "keyboard_observer.h",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_INPUT_TRACE_H_
#define COMPONENTS_EXO_INPUT_TRACE_H_
#include "base/time/time.h"
#include "ui/events/event.h"
#define TRACE_EXO_INPUT_EVENT(event) \
TRACE_EVENT2("exo", "Input::OnInputEvent", "type", event->type(), \
"timestamp", \
(event->time_stamp() - base::TimeTicks()).InMicroseconds());
#endif // COMPONENTS_EXO_INPUT_TRACE_H_
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/exo/input_trace.h"
#include "components/exo/keyboard_delegate.h" #include "components/exo/keyboard_delegate.h"
#include "components/exo/keyboard_device_configuration_delegate.h" #include "components/exo/keyboard_device_configuration_delegate.h"
#include "components/exo/seat.h" #include "components/exo/seat.h"
...@@ -231,6 +232,8 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) { ...@@ -231,6 +232,8 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) {
if (event->is_repeat()) if (event->is_repeat())
return; return;
TRACE_EXO_INPUT_EVENT(event);
// Process reserved accelerators before sending it to client. // Process reserved accelerators before sending it to client.
if (ProcessAcceleratorIfReserved(focus_, event)) { if (ProcessAcceleratorIfReserved(focus_, event)) {
// Discard a key press event if it's a reserved accelerator and it's // Discard a key press event if it's a reserved accelerator and it's
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "components/exo/input_trace.h"
#include "components/exo/pointer_delegate.h" #include "components/exo/pointer_delegate.h"
#include "components/exo/pointer_gesture_pinch_delegate.h" #include "components/exo/pointer_gesture_pinch_delegate.h"
#include "components/exo/relative_pointer_delegate.h" #include "components/exo/relative_pointer_delegate.h"
...@@ -322,6 +323,8 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) { ...@@ -322,6 +323,8 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) {
if (!focus_surface_) if (!focus_surface_)
return; return;
TRACE_EXO_INPUT_EVENT(event);
if (event->IsMouseEvent() && if (event->IsMouseEvent() &&
event->type() != ui::ET_MOUSE_EXITED && event->type() != ui::ET_MOUSE_EXITED &&
event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) {
...@@ -430,6 +433,8 @@ void Pointer::OnGestureEvent(ui::GestureEvent* event) { ...@@ -430,6 +433,8 @@ void Pointer::OnGestureEvent(ui::GestureEvent* event) {
if (!focus_surface_ || !pinch_delegate_) if (!focus_surface_ || !pinch_delegate_)
return; return;
TRACE_EXO_INPUT_EVENT(event);
switch (event->type()) { switch (event->type()) {
case ui::ET_GESTURE_PINCH_BEGIN: case ui::ET_GESTURE_PINCH_BEGIN:
pinch_delegate_->OnPointerPinchBegin(event->unique_touch_event_id(), pinch_delegate_->OnPointerPinchBegin(event->unique_touch_event_id(),
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "components/exo/touch.h" #include "components/exo/touch.h"
#include "components/exo/input_trace.h"
#include "components/exo/shell_surface_util.h" #include "components/exo/shell_surface_util.h"
#include "components/exo/surface.h" #include "components/exo/surface.h"
#include "components/exo/touch_delegate.h" #include "components/exo/touch_delegate.h"
...@@ -78,6 +80,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) { ...@@ -78,6 +80,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) {
if (!target) if (!target)
return; return;
TRACE_EXO_INPUT_EVENT(event);
// If this is the first touch point then target becomes the focus surface // If this is the first touch point then target becomes the focus surface
// until all touch points have been released. // until all touch points have been released.
if (touch_points_.empty()) { if (touch_points_.empty()) {
...@@ -109,6 +113,9 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) { ...@@ -109,6 +113,9 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) {
auto it = FindVectorItem(touch_points_, touch_pointer_id); auto it = FindVectorItem(touch_points_, touch_pointer_id);
if (it == touch_points_.end()) if (it == touch_points_.end())
return; return;
TRACE_EXO_INPUT_EVENT(event);
touch_points_.erase(it); touch_points_.erase(it);
// Reset focus surface if this is the last touch point. // Reset focus surface if this is the last touch point.
...@@ -125,6 +132,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) { ...@@ -125,6 +132,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) {
if (it == touch_points_.end()) if (it == touch_points_.end())
return; return;
TRACE_EXO_INPUT_EVENT(event);
DCHECK(focus_); DCHECK(focus_);
// Convert location to focus surface coordinate space. // Convert location to focus surface coordinate space.
gfx::PointF location = EventLocationInWindow(event, focus_->window()); gfx::PointF location = EventLocationInWindow(event, focus_->window());
...@@ -136,6 +145,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) { ...@@ -136,6 +145,8 @@ void Touch::OnTouchEvent(ui::TouchEvent* event) {
if (it == touch_points_.end()) if (it == touch_points_.end())
return; return;
TRACE_EXO_INPUT_EVENT(event);
DCHECK(focus_); DCHECK(focus_);
focus_->RemoveSurfaceObserver(this); focus_->RemoveSurfaceObserver(this);
focus_ = nullptr; focus_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment