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

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: test 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), 1144 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(),
1137 window ? window->GetWindow() : nullptr); 1145 window ? window->GetWindow() : nullptr);
1138 } 1146 }
1139 1147
1140 // TODO: use |display_id| to find host and send there. 1148 // TODO: use |display_id| to find host and send there.
1141 if (!window || !window->GetWindow()->GetHost()) { 1149 if (!window || !window->GetWindow()->GetHost()) {
1142 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); 1150 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED);
1143 return; 1151 return;
1144 } 1152 }
1145 1153
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
1158 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); 1154 EventAckHandler ack_handler(CreateEventResultCallback(event_id));
1159 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or 1155 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or
1160 // ui::TouchEvent once we have proper support for pointer events. 1156 // ui::TouchEvent once we have proper support for pointer events.
1161 if (event->IsMousePointerEvent()) { 1157 if (event->IsMousePointerEvent()) {
1162 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { 1158 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) {
1163 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); 1159 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent());
1164 host->SendEventToProcessor(&mapped_event); 1160 DispatchEventToTarget(&mapped_event, window);
1165 } else { 1161 } else {
1166 ui::MouseEvent mapped_event(*event->AsPointerEvent()); 1162 ui::MouseEvent mapped_event(*event->AsPointerEvent());
1167 host->SendEventToProcessor(&mapped_event); 1163 DispatchEventToTarget(&mapped_event, window);
1168 } 1164 }
1169 } else if (event->IsTouchPointerEvent()) { 1165 } else if (event->IsTouchPointerEvent()) {
1170 ui::TouchEvent mapped_event(*event->AsPointerEvent()); 1166 ui::TouchEvent mapped_event(*event->AsPointerEvent());
1171 host->SendEventToProcessor(&mapped_event); 1167 DispatchEventToTarget(&mapped_event, window);
1172 } else { 1168 } else {
1173 host->SendEventToProcessor(event.get()); 1169 DispatchEventToTarget(event.get(), window);
1174 } 1170 }
1175 ack_handler.set_handled(event->handled()); 1171 ack_handler.set_handled(event->handled());
1176 } 1172 }
1177 1173
1178 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, 1174 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event,
1179 uint32_t window_id, 1175 uint32_t window_id,
1180 int64_t display_id) { 1176 int64_t display_id) {
1181 DCHECK(event); 1177 DCHECK(event);
1182 DCHECK(event->IsPointerEvent()); 1178 DCHECK(event->IsPointerEvent());
1183 if (!has_pointer_watcher_) 1179 if (!has_pointer_watcher_)
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1817 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1822 this, capture_synchronizer_.get(), window)); 1818 this, capture_synchronizer_.get(), window));
1823 } 1819 }
1824 1820
1825 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1821 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1826 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1822 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1827 this, focus_synchronizer_.get(), window)); 1823 this, focus_synchronizer_.get(), window));
1828 } 1824 }
1829 1825
1830 } // namespace aura 1826 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698