OLD | NEW |
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 Loading... |
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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), | 1163 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), |
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); | |
1166 DCHECK(host); | |
1167 | |
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)); | 1173 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
1178 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1174 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
1179 // ui::TouchEvent once we have proper support for pointer events. | 1175 // ui::TouchEvent once we have proper support for pointer events. |
1180 if (event->IsMousePointerEvent()) { | 1176 if (event->IsMousePointerEvent()) { |
1181 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1177 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { |
1182 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1178 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); |
1183 host->SendEventToProcessor(&mapped_event); | 1179 DispatchEventToTarget(&mapped_event, window); |
1184 } else { | 1180 } else { |
1185 ui::MouseEvent mapped_event(*event->AsPointerEvent()); | 1181 ui::MouseEvent mapped_event(*event->AsPointerEvent()); |
1186 host->SendEventToProcessor(&mapped_event); | 1182 DispatchEventToTarget(&mapped_event, window); |
1187 } | 1183 } |
1188 } else if (event->IsTouchPointerEvent()) { | 1184 } else if (event->IsTouchPointerEvent()) { |
1189 ui::TouchEvent mapped_event(*event->AsPointerEvent()); | 1185 ui::TouchEvent mapped_event(*event->AsPointerEvent()); |
1190 host->SendEventToProcessor(&mapped_event); | 1186 DispatchEventToTarget(&mapped_event, window); |
1191 } else { | 1187 } else { |
1192 host->SendEventToProcessor(event.get()); | 1188 DispatchEventToTarget(event.get(), window); |
1193 } | 1189 } |
1194 ack_handler.set_handled(event->handled()); | 1190 ack_handler.set_handled(event->handled()); |
1195 } | 1191 } |
1196 | 1192 |
1197 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1193 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
1198 uint32_t window_id, | 1194 uint32_t window_id, |
1199 int64_t display_id) { | 1195 int64_t display_id) { |
1200 DCHECK(event); | 1196 DCHECK(event); |
1201 DCHECK(event->IsPointerEvent()); | 1197 DCHECK(event->IsPointerEvent()); |
1202 if (!has_pointer_watcher_) | 1198 if (!has_pointer_watcher_) |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1836 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1841 this, capture_synchronizer_.get(), window)); | 1837 this, capture_synchronizer_.get(), window)); |
1842 } | 1838 } |
1843 | 1839 |
1844 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1840 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1845 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1841 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1846 this, focus_synchronizer_.get(), window)); | 1842 this, focus_synchronizer_.get(), window)); |
1847 } | 1843 } |
1848 | 1844 |
1849 } // namespace aura | 1845 } // namespace aura |
OLD | NEW |