| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 const gfx::Point host_location = | 157 const gfx::Point host_location = |
| 158 gfx::ConvertPointToDIP(display.device_scale_factor(), event->location()); | 158 gfx::ConvertPointToDIP(display.device_scale_factor(), event->location()); |
| 159 event->set_location(host_location); | 159 event->set_location(host_location); |
| 160 const gfx::Point root_location = gfx::ConvertPointToDIP( | 160 const gfx::Point root_location = gfx::ConvertPointToDIP( |
| 161 display.device_scale_factor(), event->root_location()); | 161 display.device_scale_factor(), event->root_location()); |
| 162 event->set_root_location(root_location); | 162 event->set_root_location(root_location); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Create and return a MouseEvent or TouchEvent from |event| if |event| is a |
| 166 // PointerEvent, otherwise return the copy of |event|. |
| 167 std::unique_ptr<ui::Event> MapEvent(const ui::Event& event) { |
| 168 if (event.IsMousePointerEvent()) { |
| 169 if (event.type() == ui::ET_POINTER_WHEEL_CHANGED) |
| 170 return base::MakeUnique<ui::MouseWheelEvent>(*event.AsPointerEvent()); |
| 171 return base::MakeUnique<ui::MouseEvent>(*event.AsPointerEvent()); |
| 172 } |
| 173 if (event.IsTouchPointerEvent()) |
| 174 return base::MakeUnique<ui::TouchEvent>(*event.AsPointerEvent()); |
| 175 return ui::Event::Clone(event); |
| 176 } |
| 177 |
| 165 // Set the |target| to be the target window of this |event| and send it to | 178 // Set the |target| to be the target window of this |event| and send it to |
| 166 // the EventSink. | 179 // the EventSink. |
| 167 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { | 180 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { |
| 168 ui::Event::DispatcherApi dispatch_helper(event); | 181 ui::Event::DispatcherApi dispatch_helper(event); |
| 169 dispatch_helper.set_target(target->GetWindow()); | 182 dispatch_helper.set_target(target->GetWindow()); |
| 170 GetWindowTreeHostMus(target)->SendEventToSink(event); | 183 GetWindowTreeHostMus(target)->SendEventToSink(event); |
| 171 } | 184 } |
| 172 | 185 |
| 173 } // namespace | 186 } // namespace |
| 174 | 187 |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 | 1244 |
| 1232 // TODO: use |display_id| to find host and send there. | 1245 // TODO: use |display_id| to find host and send there. |
| 1233 if (!window || !window->GetWindow()->GetHost()) { | 1246 if (!window || !window->GetWindow()->GetHost()) { |
| 1234 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1247 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
| 1235 return; | 1248 return; |
| 1236 } | 1249 } |
| 1237 | 1250 |
| 1238 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); | 1251 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
| 1239 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1252 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
| 1240 // ui::TouchEvent once we have proper support for pointer events. | 1253 // ui::TouchEvent once we have proper support for pointer events. |
| 1241 if (event->IsMousePointerEvent()) { | 1254 std::unique_ptr<ui::Event> mapped_event = MapEvent(*event.get()); |
| 1242 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1255 DispatchEventToTarget(mapped_event.get(), window); |
| 1243 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1256 ack_handler.set_handled(mapped_event->handled()); |
| 1244 DispatchEventToTarget(&mapped_event, window); | |
| 1245 } else { | |
| 1246 ui::MouseEvent mapped_event(*event->AsPointerEvent()); | |
| 1247 DispatchEventToTarget(&mapped_event, window); | |
| 1248 } | |
| 1249 } else if (event->IsTouchPointerEvent()) { | |
| 1250 ui::TouchEvent mapped_event(*event->AsPointerEvent()); | |
| 1251 DispatchEventToTarget(&mapped_event, window); | |
| 1252 } else { | |
| 1253 DispatchEventToTarget(event.get(), window); | |
| 1254 } | |
| 1255 ack_handler.set_handled(event->handled()); | |
| 1256 } | 1257 } |
| 1257 | 1258 |
| 1258 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1259 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
| 1259 uint32_t window_id, | 1260 uint32_t window_id, |
| 1260 int64_t display_id) { | 1261 int64_t display_id) { |
| 1261 DCHECK(event); | 1262 DCHECK(event); |
| 1262 DCHECK(event->IsPointerEvent()); | 1263 DCHECK(event->IsPointerEvent()); |
| 1263 if (!has_pointer_watcher_) | 1264 if (!has_pointer_watcher_) |
| 1264 return; | 1265 return; |
| 1265 | 1266 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1960 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1960 this, capture_synchronizer_.get(), window)); | 1961 this, capture_synchronizer_.get(), window)); |
| 1961 } | 1962 } |
| 1962 | 1963 |
| 1963 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1964 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1964 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1965 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1965 this, focus_synchronizer_.get(), window)); | 1966 this, focus_synchronizer_.get(), window)); |
| 1966 } | 1967 } |
| 1967 | 1968 |
| 1968 } // namespace aura | 1969 } // namespace aura |
| OLD | NEW |