Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: content/renderer/mus/compositor_mus_connection.cc

Issue 1806703002: Use ui::Event instead of mojom::EventPtr in mus::InputEventHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "mojo/converters/blink/blink_input_events_type_converters.h" 11 #include "mojo/converters/blink/blink_input_events_type_converters.h"
12 #include "mojo/converters/input_events/input_events_type_converters.h"
12 #include "ui/events/latency_info.h" 13 #include "ui/events/latency_info.h"
13 14
14 namespace { 15 namespace {
15 16
16 void DoNothingBool(bool result) {} 17 void DoNothingBool(bool result) {}
17 18
18 } // namespace 19 } // namespace
19 20
20 namespace content { 21 namespace content {
21 22
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 root_ = root; 109 root_ = root;
109 root_->set_input_event_handler(this); 110 root_->set_input_event_handler(this);
110 if (window_surface_binding_) { 111 if (window_surface_binding_) {
111 root->AttachSurface(mus::mojom::SurfaceType::DEFAULT, 112 root->AttachSurface(mus::mojom::SurfaceType::DEFAULT,
112 std::move(window_surface_binding_)); 113 std::move(window_surface_binding_));
113 } 114 }
114 } 115 }
115 116
116 void CompositorMusConnection::OnWindowInputEvent( 117 void CompositorMusConnection::OnWindowInputEvent(
117 mus::Window* window, 118 mus::Window* window,
118 mus::mojom::EventPtr event, 119 ui::Event* event,
119 scoped_ptr<base::Callback<void(bool)>>* ack_callback) { 120 scoped_ptr<base::Callback<void(bool)>>* ack_callback) {
120 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 121 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
121 scoped_ptr<blink::WebInputEvent> web_event = 122 // TODO(moshayedi): Convert ui::Event directly to blink::WebInputEvent.
122 event.To<scoped_ptr<blink::WebInputEvent>>(); 123 scoped_ptr<blink::WebInputEvent> web_event(
124 mus::mojom::Event::From(*event).To<scoped_ptr<blink::WebInputEvent>>());
123 // TODO(sad): We probably need to plumb LatencyInfo through Mus. 125 // TODO(sad): We probably need to plumb LatencyInfo through Mus.
124 ui::LatencyInfo info; 126 ui::LatencyInfo info;
125 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent( 127 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent(
126 routing_id_, web_event.get(), &info); 128 routing_id_, web_event.get(), &info);
127 // TODO(jonross): We probably need to ack the event based on the consumed 129 // TODO(jonross): We probably need to ack the event based on the consumed
128 // state. 130 // state.
129 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) 131 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
130 return; 132 return;
131 base::Callback<void(bool)> ack = base::Bind(&::DoNothingBool); 133 base::Callback<void(bool)> ack = base::Bind(&::DoNothingBool);
132 const bool send_ack = 134 const bool send_ack =
133 WebInputEventTraits::WillReceiveAckFromRenderer(*web_event); 135 WebInputEventTraits::WillReceiveAckFromRenderer(*web_event);
134 if (send_ack) { 136 if (send_ack) {
135 // Ultimately, this ACK needs to go back to the Mus client lib which is not 137 // Ultimately, this ACK needs to go back to the Mus client lib which is not
136 // thread-safe and lives on the compositor thread. For ACKs that are passed 138 // thread-safe and lives on the compositor thread. For ACKs that are passed
137 // to the main thread we pass them back to the compositor thread via 139 // to the main thread we pass them back to the compositor thread via
138 // OnWindowInputEventAckOnMainThread. 140 // OnWindowInputEventAckOnMainThread.
139 ack = 141 ack =
140 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, 142 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread,
141 this, *ack_callback->get()); 143 this, *ack_callback->get());
142 ack_callback->reset(); 144 ack_callback->reset();
143 } 145 }
144 main_task_runner_->PostTask( 146 main_task_runner_->PostTask(
145 FROM_HERE, 147 FROM_HERE,
146 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, 148 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
147 base::Passed(std::move(web_event)), ack)); 149 base::Passed(std::move(web_event)), ack));
148 } 150 }
149 151
150 } // namespace content 152 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698