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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), | 1151 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), |
1144 window ? window->GetWindow() : nullptr); | 1152 window ? window->GetWindow() : nullptr); |
1145 } | 1153 } |
1146 | 1154 |
1147 // TODO: use |display_id| to find host and send there. | 1155 // TODO: use |display_id| to find host and send there. |
1148 if (!window || !window->GetWindow()->GetHost()) { | 1156 if (!window || !window->GetWindow()->GetHost()) { |
1149 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1157 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
1150 return; | 1158 return; |
1151 } | 1159 } |
1152 | 1160 |
1153 WindowTreeHostMus* host = GetWindowTreeHostMus(window); | |
1154 DCHECK(host); | |
1155 | |
1156 // The location of the event is relative to |window|. As the event is handed | |
1157 // to WindowTreeHost we need it to be relative to WindowTreeHost. | |
1158 if (event->IsLocatedEvent()) { | |
1159 gfx::Point host_location = event->AsLocatedEvent()->location(); | |
1160 aura::Window::ConvertPointToTarget(window->GetWindow(), host->window(), | |
1161 &host_location); | |
1162 event->AsLocatedEvent()->set_location(host_location); | |
1163 } | |
1164 | |
1165 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); | 1161 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
1166 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1162 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
1167 // ui::TouchEvent once we have proper support for pointer events. | 1163 // ui::TouchEvent once we have proper support for pointer events. |
1168 if (event->IsMousePointerEvent()) { | 1164 if (event->IsMousePointerEvent()) { |
1169 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1165 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { |
1170 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1166 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); |
1171 host->SendEventToProcessor(&mapped_event); | 1167 DispatchEventToTarget(&mapped_event, window); |
1172 } else { | 1168 } else { |
1173 ui::MouseEvent mapped_event(*event->AsPointerEvent()); | 1169 ui::MouseEvent mapped_event(*event->AsPointerEvent()); |
1174 host->SendEventToProcessor(&mapped_event); | 1170 DispatchEventToTarget(&mapped_event, window); |
1175 } | 1171 } |
1176 } else if (event->IsTouchPointerEvent()) { | 1172 } else if (event->IsTouchPointerEvent()) { |
1177 ui::TouchEvent mapped_event(*event->AsPointerEvent()); | 1173 ui::TouchEvent mapped_event(*event->AsPointerEvent()); |
1178 host->SendEventToProcessor(&mapped_event); | 1174 DispatchEventToTarget(&mapped_event, window); |
1179 } else { | 1175 } else { |
1180 host->SendEventToProcessor(event.get()); | 1176 DispatchEventToTarget(event.get(), window); |
1181 } | 1177 } |
1182 ack_handler.set_handled(event->handled()); | 1178 ack_handler.set_handled(event->handled()); |
1183 } | 1179 } |
1184 | 1180 |
1185 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1181 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
1186 uint32_t window_id, | 1182 uint32_t window_id, |
1187 int64_t display_id) { | 1183 int64_t display_id) { |
1188 DCHECK(event); | 1184 DCHECK(event); |
1189 DCHECK(event->IsPointerEvent()); | 1185 DCHECK(event->IsPointerEvent()); |
1190 if (!has_pointer_watcher_) | 1186 if (!has_pointer_watcher_) |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1824 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1829 this, capture_synchronizer_.get(), window)); | 1825 this, capture_synchronizer_.get(), window)); |
1830 } | 1826 } |
1831 | 1827 |
1832 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1828 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1833 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1829 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1834 this, focus_synchronizer_.get(), window)); | 1830 this, focus_synchronizer_.get(), window)); |
1835 } | 1831 } |
1836 | 1832 |
1837 } // namespace aura | 1833 } // namespace aura |
OLD | NEW |