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

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

Issue 2715743005: Revert of Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: 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
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
171 } // namespace 163 } // namespace
172 164
173 WindowTreeClient::WindowTreeClient( 165 WindowTreeClient::WindowTreeClient(
174 service_manager::Connector* connector, 166 service_manager::Connector* connector,
175 WindowTreeClientDelegate* delegate, 167 WindowTreeClientDelegate* delegate,
176 WindowManagerDelegate* window_manager_delegate, 168 WindowManagerDelegate* window_manager_delegate,
177 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, 169 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
178 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) 170 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
179 : connector_(connector), 171 : connector_(connector),
180 client_id_(0), 172 client_id_(0),
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), 1136 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(),
1145 window ? window->GetWindow() : nullptr); 1137 window ? window->GetWindow() : nullptr);
1146 } 1138 }
1147 1139
1148 // TODO: use |display_id| to find host and send there. 1140 // TODO: use |display_id| to find host and send there.
1149 if (!window || !window->GetWindow()->GetHost()) { 1141 if (!window || !window->GetWindow()->GetHost()) {
1150 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); 1142 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED);
1151 return; 1143 return;
1152 } 1144 }
1153 1145
1146 WindowTreeHostMus* host = GetWindowTreeHostMus(window);
1147 DCHECK(host);
1148
1149 // The location of the event is relative to |window|. As the event is handed
1150 // to WindowTreeHost we need it to be relative to WindowTreeHost.
1151 if (event->IsLocatedEvent()) {
1152 gfx::Point host_location = event->AsLocatedEvent()->location();
1153 aura::Window::ConvertPointToTarget(window->GetWindow(), host->window(),
1154 &host_location);
1155 event->AsLocatedEvent()->set_location(host_location);
1156 }
1157
1154 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); 1158 EventAckHandler ack_handler(CreateEventResultCallback(event_id));
1155 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or 1159 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or
1156 // ui::TouchEvent once we have proper support for pointer events. 1160 // ui::TouchEvent once we have proper support for pointer events.
1157 if (event->IsMousePointerEvent()) { 1161 if (event->IsMousePointerEvent()) {
1158 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { 1162 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) {
1159 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); 1163 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent());
1160 DispatchEventToTarget(&mapped_event, window); 1164 host->SendEventToProcessor(&mapped_event);
1161 } else { 1165 } else {
1162 ui::MouseEvent mapped_event(*event->AsPointerEvent()); 1166 ui::MouseEvent mapped_event(*event->AsPointerEvent());
1163 DispatchEventToTarget(&mapped_event, window); 1167 host->SendEventToProcessor(&mapped_event);
1164 } 1168 }
1165 } else if (event->IsTouchPointerEvent()) { 1169 } else if (event->IsTouchPointerEvent()) {
1166 ui::TouchEvent mapped_event(*event->AsPointerEvent()); 1170 ui::TouchEvent mapped_event(*event->AsPointerEvent());
1167 DispatchEventToTarget(&mapped_event, window); 1171 host->SendEventToProcessor(&mapped_event);
1168 } else { 1172 } else {
1169 DispatchEventToTarget(event.get(), window); 1173 host->SendEventToProcessor(event.get());
1170 } 1174 }
1171 ack_handler.set_handled(event->handled()); 1175 ack_handler.set_handled(event->handled());
1172 } 1176 }
1173 1177
1174 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, 1178 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event,
1175 uint32_t window_id, 1179 uint32_t window_id,
1176 int64_t display_id) { 1180 int64_t display_id) {
1177 DCHECK(event); 1181 DCHECK(event);
1178 DCHECK(event->IsPointerEvent()); 1182 DCHECK(event->IsPointerEvent());
1179 if (!has_pointer_watcher_) 1183 if (!has_pointer_watcher_)
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1821 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1818 this, capture_synchronizer_.get(), window)); 1822 this, capture_synchronizer_.get(), window));
1819 } 1823 }
1820 1824
1821 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1825 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1822 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1826 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1823 this, focus_synchronizer_.get(), window)); 1827 this, focus_synchronizer_.get(), window));
1824 } 1828 }
1825 1829
1826 } // namespace aura 1830 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698