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 std::unique_ptr<ui::Event> MapEvent(const ui::Event& event) { | |
sky
2017/03/31 20:57:30
Please add a comment.
riajiang
2017/03/31 21:17:41
Done.
| |
166 if (event.IsMousePointerEvent()) { | |
167 if (event.type() == ui::ET_POINTER_WHEEL_CHANGED) | |
168 return base::MakeUnique<ui::MouseWheelEvent>(*event.AsPointerEvent()); | |
169 return base::MakeUnique<ui::MouseEvent>(*event.AsPointerEvent()); | |
170 } else if (event.IsTouchPointerEvent()) { | |
sky
2017/03/31 20:57:30
no else after return (see chromium style guide).
riajiang
2017/03/31 21:17:41
Done.
| |
171 return base::MakeUnique<ui::TouchEvent>(*event.AsPointerEvent()); | |
172 } | |
173 return ui::Event::Clone(event); | |
174 } | |
175 | |
165 // Set the |target| to be the target window of this |event| and send it to | 176 // Set the |target| to be the target window of this |event| and send it to |
166 // the EventSink. | 177 // the EventSink. |
167 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { | 178 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { |
168 ui::Event::DispatcherApi dispatch_helper(event); | 179 ui::Event::DispatcherApi dispatch_helper(event); |
169 dispatch_helper.set_target(target->GetWindow()); | 180 dispatch_helper.set_target(target->GetWindow()); |
170 GetWindowTreeHostMus(target)->SendEventToSink(event); | 181 GetWindowTreeHostMus(target)->SendEventToSink(event); |
171 } | 182 } |
172 | 183 |
173 } // namespace | 184 } // namespace |
174 | 185 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 | 1242 |
1232 // TODO: use |display_id| to find host and send there. | 1243 // TODO: use |display_id| to find host and send there. |
1233 if (!window || !window->GetWindow()->GetHost()) { | 1244 if (!window || !window->GetWindow()->GetHost()) { |
1234 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1245 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
1235 return; | 1246 return; |
1236 } | 1247 } |
1237 | 1248 |
1238 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); | 1249 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
1239 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1250 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
1240 // ui::TouchEvent once we have proper support for pointer events. | 1251 // ui::TouchEvent once we have proper support for pointer events. |
1241 if (event->IsMousePointerEvent()) { | 1252 std::unique_ptr<ui::Event> mapped_event = MapEvent(*event.get()); |
1242 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1253 DispatchEventToTarget(mapped_event.get(), window); |
1243 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1254 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 } | 1255 } |
1257 | 1256 |
1258 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1257 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
1259 uint32_t window_id, | 1258 uint32_t window_id, |
1260 int64_t display_id) { | 1259 int64_t display_id) { |
1261 DCHECK(event); | 1260 DCHECK(event); |
1262 DCHECK(event->IsPointerEvent()); | 1261 DCHECK(event->IsPointerEvent()); |
1263 if (!has_pointer_watcher_) | 1262 if (!has_pointer_watcher_) |
1264 return; | 1263 return; |
1265 | 1264 |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1959 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1958 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1960 this, capture_synchronizer_.get(), window)); | 1959 this, capture_synchronizer_.get(), window)); |
1961 } | 1960 } |
1962 | 1961 |
1963 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1962 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1964 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1963 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1965 this, focus_synchronizer_.get(), window)); | 1964 this, focus_synchronizer_.get(), window)); |
1966 } | 1965 } |
1967 | 1966 |
1968 } // namespace aura | 1967 } // namespace aura |
OLD | NEW |