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

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2681613002: Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: nits and tests Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return; 153 return;
154 } 154 }
155 const gfx::Point host_location = 155 const gfx::Point host_location =
156 gfx::ConvertPointToDIP(display.device_scale_factor(), event->location()); 156 gfx::ConvertPointToDIP(display.device_scale_factor(), event->location());
157 event->set_location(host_location); 157 event->set_location(host_location);
158 const gfx::Point root_location = gfx::ConvertPointToDIP( 158 const gfx::Point root_location = gfx::ConvertPointToDIP(
159 display.device_scale_factor(), event->root_location()); 159 display.device_scale_factor(), event->root_location());
160 event->set_root_location(root_location); 160 event->set_root_location(root_location);
161 } 161 }
162 162
163 // Set the |target| to be the target window of this |event| and send it to
164 // the EventProcessor.
165 void DispatchEventToTarget(ui::Event* event, WindowMus* target) {
166 ui::Event::DispatcherApi dispatch_helper(event);
167 dispatch_helper.set_target(target->GetWindow());
168 GetWindowTreeHostMus(target)->SendEventToProcessor(event);
169 }
170
163 } // namespace 171 } // namespace
164 172
165 WindowTreeClient::WindowTreeClient( 173 WindowTreeClient::WindowTreeClient(
166 service_manager::Connector* connector, 174 service_manager::Connector* connector,
167 WindowTreeClientDelegate* delegate, 175 WindowTreeClientDelegate* delegate,
168 WindowManagerDelegate* window_manager_delegate, 176 WindowManagerDelegate* window_manager_delegate,
169 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, 177 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
170 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) 178 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
171 : connector_(connector), 179 : connector_(connector),
172 client_id_(0), 180 client_id_(0),
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 window ? window->GetWindow() : nullptr); 1164 window ? window->GetWindow() : nullptr);
1157 } 1165 }
1158 1166
1159 // TODO: use |display_id| to find host and send there. 1167 // TODO: use |display_id| to find host and send there.
1160 if (!window || !window->GetWindow()->GetHost()) { 1168 if (!window || !window->GetWindow()->GetHost()) {
1161 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); 1169 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED);
1162 return; 1170 return;
1163 } 1171 }
1164 1172
1165 WindowTreeHostMus* host = GetWindowTreeHostMus(window); 1173 WindowTreeHostMus* host = GetWindowTreeHostMus(window);
1166 DCHECK(host); 1174 DCHECK(host);
sadrul 2017/02/14 21:40:10 |host| is no longer used I think? Remove.
riajiang 2017/02/15 18:09:27 True. Done.
1167 1175
1168 // The location of the event is relative to |window|. As the event is handed
1169 // to WindowTreeHost we need it to be relative to WindowTreeHost.
1170 if (event->IsLocatedEvent()) {
1171 gfx::Point host_location = event->AsLocatedEvent()->location();
1172 aura::Window::ConvertPointToTarget(window->GetWindow(), host->window(),
1173 &host_location);
1174 event->AsLocatedEvent()->set_location(host_location);
1175 }
1176
1177 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); 1176 EventAckHandler ack_handler(CreateEventResultCallback(event_id));
1178 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or 1177 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or
1179 // ui::TouchEvent once we have proper support for pointer events. 1178 // ui::TouchEvent once we have proper support for pointer events.
1180 if (event->IsMousePointerEvent()) { 1179 if (event->IsMousePointerEvent()) {
1181 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { 1180 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) {
1182 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); 1181 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent());
1183 host->SendEventToProcessor(&mapped_event); 1182 DispatchEventToTarget(&mapped_event, window);
1184 } else { 1183 } else {
1185 ui::MouseEvent mapped_event(*event->AsPointerEvent()); 1184 ui::MouseEvent mapped_event(*event->AsPointerEvent());
1186 host->SendEventToProcessor(&mapped_event); 1185 DispatchEventToTarget(&mapped_event, window);
1187 } 1186 }
1188 } else if (event->IsTouchPointerEvent()) { 1187 } else if (event->IsTouchPointerEvent()) {
1189 ui::TouchEvent mapped_event(*event->AsPointerEvent()); 1188 ui::TouchEvent mapped_event(*event->AsPointerEvent());
1190 host->SendEventToProcessor(&mapped_event); 1189 DispatchEventToTarget(&mapped_event, window);
1191 } else { 1190 } else {
1192 host->SendEventToProcessor(event.get()); 1191 DispatchEventToTarget(event.get(), window);
1193 } 1192 }
1194 ack_handler.set_handled(event->handled()); 1193 ack_handler.set_handled(event->handled());
1195 } 1194 }
1196 1195
1197 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, 1196 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event,
1198 uint32_t window_id, 1197 uint32_t window_id,
1199 int64_t display_id) { 1198 int64_t display_id) {
1200 DCHECK(event); 1199 DCHECK(event);
1201 DCHECK(event->IsPointerEvent()); 1200 DCHECK(event->IsPointerEvent());
1202 if (!has_pointer_watcher_) 1201 if (!has_pointer_watcher_)
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1835 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1837 this, capture_synchronizer_.get(), window)); 1836 this, capture_synchronizer_.get(), window));
1838 } 1837 }
1839 1838
1840 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1839 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1841 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1840 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1842 this, focus_synchronizer_.get(), window)); 1841 this, focus_synchronizer_.get(), window));
1843 } 1842 }
1844 1843
1845 } // namespace aura 1844 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698