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 the | |
164 // EventProcessor. | |
165 void DispatchEventToTarget(ui::Event* event, | |
166 Window* target, | |
167 WindowTreeHostMus* host) { | |
168 ui::Event::DispatcherApi dispatch_helper(event); | |
sadrul
2017/02/13 17:05:42
This can just take the ui::Event, and the WindowMu
riajiang
2017/02/13 23:30:34
Done.
| |
169 dispatch_helper.set_target(target); | |
170 host->SendEventToProcessor(event); | |
171 } | |
172 | |
163 } // namespace | 173 } // namespace |
164 | 174 |
165 WindowTreeClient::WindowTreeClient( | 175 WindowTreeClient::WindowTreeClient( |
166 service_manager::Connector* connector, | 176 service_manager::Connector* connector, |
167 WindowTreeClientDelegate* delegate, | 177 WindowTreeClientDelegate* delegate, |
168 WindowManagerDelegate* window_manager_delegate, | 178 WindowManagerDelegate* window_manager_delegate, |
169 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, | 179 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, |
170 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | 180 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) |
171 : connector_(connector), | 181 : connector_(connector), |
172 client_id_(0), | 182 client_id_(0), |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 | 1168 |
1159 // TODO: use |display_id| to find host and send there. | 1169 // TODO: use |display_id| to find host and send there. |
1160 if (!window || !window->GetWindow()->GetHost()) { | 1170 if (!window || !window->GetWindow()->GetHost()) { |
1161 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1171 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
1162 return; | 1172 return; |
1163 } | 1173 } |
1164 | 1174 |
1165 WindowTreeHostMus* host = GetWindowTreeHostMus(window); | 1175 WindowTreeHostMus* host = GetWindowTreeHostMus(window); |
1166 DCHECK(host); | 1176 DCHECK(host); |
1167 | 1177 |
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)); | 1178 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
1178 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1179 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
1179 // ui::TouchEvent once we have proper support for pointer events. | 1180 // ui::TouchEvent once we have proper support for pointer events. |
1180 if (event->IsMousePointerEvent()) { | 1181 if (event->IsMousePointerEvent()) { |
1181 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1182 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { |
1182 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1183 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); |
1183 host->SendEventToProcessor(&mapped_event); | 1184 DispatchEventToTarget(&mapped_event, window->GetWindow(), host); |
1184 } else { | 1185 } else { |
1185 ui::MouseEvent mapped_event(*event->AsPointerEvent()); | 1186 ui::MouseEvent mapped_event(*event->AsPointerEvent()); |
1186 host->SendEventToProcessor(&mapped_event); | 1187 DispatchEventToTarget(&mapped_event, window->GetWindow(), host); |
1187 } | 1188 } |
1188 } else if (event->IsTouchPointerEvent()) { | 1189 } else if (event->IsTouchPointerEvent()) { |
1189 ui::TouchEvent mapped_event(*event->AsPointerEvent()); | 1190 ui::TouchEvent mapped_event(*event->AsPointerEvent()); |
1190 host->SendEventToProcessor(&mapped_event); | 1191 DispatchEventToTarget(&mapped_event, window->GetWindow(), host); |
1191 } else { | 1192 } else { |
1192 host->SendEventToProcessor(event.get()); | 1193 DispatchEventToTarget(event.get(), window->GetWindow(), host); |
1193 } | 1194 } |
1194 ack_handler.set_handled(event->handled()); | 1195 ack_handler.set_handled(event->handled()); |
1195 } | 1196 } |
1196 | 1197 |
1197 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1198 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
1198 uint32_t window_id, | 1199 uint32_t window_id, |
1199 int64_t display_id) { | 1200 int64_t display_id) { |
1200 DCHECK(event); | 1201 DCHECK(event); |
1201 DCHECK(event->IsPointerEvent()); | 1202 DCHECK(event->IsPointerEvent()); |
1202 if (!has_pointer_watcher_) | 1203 if (!has_pointer_watcher_) |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1836 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1837 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1837 this, capture_synchronizer_.get(), window)); | 1838 this, capture_synchronizer_.get(), window)); |
1838 } | 1839 } |
1839 | 1840 |
1840 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1841 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1841 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1842 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1842 this, focus_synchronizer_.get(), window)); | 1843 this, focus_synchronizer_.get(), window)); |
1843 } | 1844 } |
1844 | 1845 |
1845 } // namespace aura | 1846 } // namespace aura |
OLD | NEW |