| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/mus/compositor_mus_connection.h" | 5 #include "content/renderer/mus/compositor_mus_connection.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "content/common/input/web_input_event_traits.h" | 8 #include "content/common/input/web_input_event_traits.h" |
| 9 #include "content/renderer/input/input_handler_manager.h" | 9 #include "content/renderer/input/input_handler_manager.h" |
| 10 #include "content/renderer/mus/render_widget_mus_connection.h" | 10 #include "content/renderer/mus/render_widget_mus_connection.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 void CompositorMusConnection::OnEventObserved(const ui::Event& event) { | 119 void CompositorMusConnection::OnEventObserved(const ui::Event& event) { |
| 120 // Compositor does not use SetEventObserver(). | 120 // Compositor does not use SetEventObserver(). |
| 121 } | 121 } |
| 122 | 122 |
| 123 void CompositorMusConnection::OnWindowInputEvent( | 123 void CompositorMusConnection::OnWindowInputEvent( |
| 124 mus::Window* window, | 124 mus::Window* window, |
| 125 const ui::Event& event, | 125 const ui::Event& event, |
| 126 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { | 126 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { |
| 127 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 127 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 128 // TODO(moshayedi): Convert ui::Event directly to blink::WebInputEvent. | |
| 129 std::unique_ptr<blink::WebInputEvent> web_event( | 128 std::unique_ptr<blink::WebInputEvent> web_event( |
| 130 mus::mojom::Event::From(event) | 129 mojo::TypeConverter<std::unique_ptr<blink::WebInputEvent>, |
| 131 .To<std::unique_ptr<blink::WebInputEvent>>()); | 130 ui::Event>::Convert(event)); |
| 132 // TODO(sad): We probably need to plumb LatencyInfo through Mus. | 131 // TODO(sad): We probably need to plumb LatencyInfo through Mus. |
| 133 ui::LatencyInfo info; | 132 ui::LatencyInfo info; |
| 134 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent( | 133 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent( |
| 135 routing_id_, web_event.get(), &info); | 134 routing_id_, web_event.get(), &info); |
| 136 // TODO(jonross): We probably need to ack the event based on the consumed | 135 // TODO(jonross): We probably need to ack the event based on the consumed |
| 137 // state. | 136 // state. |
| 138 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) | 137 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) |
| 139 return; | 138 return; |
| 140 base::Callback<void(EventResult)> ack = | 139 base::Callback<void(EventResult)> ack = |
| 141 base::Bind(&::DoNothingWithEventResult); | 140 base::Bind(&::DoNothingWithEventResult); |
| 142 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event); | 141 const bool send_ack = WebInputEventTraits::ShouldBlockEventStream(*web_event); |
| 143 if (send_ack) { | 142 if (send_ack) { |
| 144 // Ultimately, this ACK needs to go back to the Mus client lib which is not | 143 // Ultimately, this ACK needs to go back to the Mus client lib which is not |
| 145 // thread-safe and lives on the compositor thread. For ACKs that are passed | 144 // thread-safe and lives on the compositor thread. For ACKs that are passed |
| 146 // to the main thread we pass them back to the compositor thread via | 145 // to the main thread we pass them back to the compositor thread via |
| 147 // OnWindowInputEventAckOnMainThread. | 146 // OnWindowInputEventAckOnMainThread. |
| 148 ack = | 147 ack = |
| 149 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, | 148 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, |
| 150 this, *ack_callback->get()); | 149 this, *ack_callback->get()); |
| 151 ack_callback->reset(); | 150 ack_callback->reset(); |
| 152 } | 151 } |
| 153 main_task_runner_->PostTask( | 152 main_task_runner_->PostTask( |
| 154 FROM_HERE, | 153 FROM_HERE, |
| 155 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, | 154 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, |
| 156 base::Passed(std::move(web_event)), ack)); | 155 base::Passed(std::move(web_event)), ack)); |
| 157 } | 156 } |
| 158 | 157 |
| 159 } // namespace content | 158 } // namespace content |
| OLD | NEW |