OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/input_manager/input_dispatcher_impl.h" | 5 #include "services/ui/input_manager/input_dispatcher_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "mojo/services/geometry/cpp/geometry_util.h" | 10 #include "mojo/services/geometry/cpp/geometry_util.h" |
11 #include "mojo/services/gfx/composition/cpp/formatting.h" | 11 #include "mojo/services/gfx/composition/cpp/formatting.h" |
12 #include "mojo/services/ui/views/cpp/formatting.h" | 12 #include "mojo/services/ui/views/cpp/formatting.h" |
13 #include "services/ui/input_manager/input_associate.h" | 13 #include "services/ui/input_manager/input_associate.h" |
14 | 14 |
15 namespace input_manager { | 15 namespace input_manager { |
16 namespace { | 16 namespace { |
17 void TransformEvent(const mojo::Transform& transform, mojo::Event* event) { | 17 void TransformEvent(const mojo::Transform& transform, mojo::Event* event) { |
18 if (!event->pointer_data) | 18 if (!event->pointer_data) |
19 return; | 19 return; |
20 mojo::Point point; | 20 mojo::PointF point; |
21 point.x = event->pointer_data->x; | 21 point.x = event->pointer_data->x; |
22 point.y = event->pointer_data->y; | 22 point.y = event->pointer_data->y; |
23 point = TransformPoint(transform, point); | 23 point = TransformPoint(transform, point); |
24 event->pointer_data->x = point.x; | 24 event->pointer_data->x = point.x; |
25 event->pointer_data->y = point.y; | 25 event->pointer_data->y = point.y; |
26 } | 26 } |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 InputDispatcherImpl::InputDispatcherImpl( | 29 InputDispatcherImpl::InputDispatcherImpl( |
30 InputAssociate* associate, | 30 InputAssociate* associate, |
(...skipping 24 matching lines...) Expand all Loading... |
55 ProcessNextEvent(); | 55 ProcessNextEvent(); |
56 } | 56 } |
57 | 57 |
58 void InputDispatcherImpl::ProcessNextEvent() { | 58 void InputDispatcherImpl::ProcessNextEvent() { |
59 DCHECK(!pending_events_.empty()); | 59 DCHECK(!pending_events_.empty()); |
60 | 60 |
61 do { | 61 do { |
62 const mojo::Event* event = pending_events_.front().get(); | 62 const mojo::Event* event = pending_events_.front().get(); |
63 if (event->action == mojo::EventType::POINTER_DOWN) { | 63 if (event->action == mojo::EventType::POINTER_DOWN) { |
64 DCHECK(event->pointer_data); | 64 DCHECK(event->pointer_data); |
65 auto point = mojo::Point::New(); | 65 auto point = mojo::PointF::New(); |
66 point->x = event->pointer_data->x; | 66 point->x = event->pointer_data->x; |
67 point->y = event->pointer_data->y; | 67 point->y = event->pointer_data->y; |
68 DVLOG(1) << "HitTest: point=" << point; | 68 DVLOG(1) << "HitTest: point=" << point; |
69 hit_tester_->HitTest(point.Pass(), | 69 hit_tester_->HitTest(point.Pass(), |
70 base::Bind(&InputDispatcherImpl::OnHitTestResult, | 70 base::Bind(&InputDispatcherImpl::OnHitTestResult, |
71 weak_factory_.GetWeakPtr())); | 71 weak_factory_.GetWeakPtr())); |
72 return; | 72 return; |
73 } | 73 } |
74 DeliverEvent(pending_events_.front().Pass()); | 74 DeliverEvent(pending_events_.front().Pass()); |
75 pending_events_.pop(); | 75 pending_events_.pop(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 if (!pending_events_.empty()) { | 121 if (!pending_events_.empty()) { |
122 // Prevent reentrance from ProcessNextEvent. | 122 // Prevent reentrance from ProcessNextEvent. |
123 base::MessageLoop::current()->PostTask( | 123 base::MessageLoop::current()->PostTask( |
124 FROM_HERE, base::Bind(&InputDispatcherImpl::ProcessNextEvent, | 124 FROM_HERE, base::Bind(&InputDispatcherImpl::ProcessNextEvent, |
125 weak_factory_.GetWeakPtr())); | 125 weak_factory_.GetWeakPtr())); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 } // namespace input_manager | 129 } // namespace input_manager |
OLD | NEW |