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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1142 // dispatch a window is deleted or moved. In either case we still need to | 1142 // dispatch a window is deleted or moved. In either case we still need to |
1143 // dispatch. Most likely need the display id. | 1143 // dispatch. Most likely need the display id. |
1144 if (!window || !window->GetWindow()->GetHost()) { | 1144 if (!window || !window->GetWindow()->GetHost()) { |
1145 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1145 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
1146 return; | 1146 return; |
1147 } | 1147 } |
1148 | 1148 |
1149 WindowTreeHostMus* host = GetWindowTreeHostMus(window); | 1149 WindowTreeHostMus* host = GetWindowTreeHostMus(window); |
1150 DCHECK(host); | 1150 DCHECK(host); |
1151 | 1151 |
1152 // The location of the event is relative to |window|. As the event is handed | |
1153 // to WindowTreeHost we need it to be relative to WindowTreeHost. | |
1154 if (event->IsLocatedEvent()) { | |
1155 gfx::Point host_location = event->AsLocatedEvent()->location(); | |
1156 aura::Window::ConvertPointToTarget(window->GetWindow(), host->window(), | |
1157 &host_location); | |
1158 event->AsLocatedEvent()->set_location(host_location); | |
1159 } | |
1160 | |
1161 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); | 1152 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); |
1162 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or | 1153 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
1163 // ui::TouchEvent once we have proper support for pointer events. | 1154 // ui::TouchEvent once we have proper support for pointer events. |
1164 if (event->IsMousePointerEvent()) { | 1155 if (event->IsMousePointerEvent()) { |
1165 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { | 1156 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { |
1166 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); | 1157 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); |
1158 // Set the target window of this event to be the window received from mus | |
1159 // window server. EventProcessor will use this target window for event | |
1160 // dispatching instead of trying to find the right target window again. | |
1161 ui::Event::DispatcherApi dispatch_helper(&mapped_event); | |
1162 dispatch_helper.set_target(window->GetWindow()); | |
1167 host->SendEventToProcessor(&mapped_event); | 1163 host->SendEventToProcessor(&mapped_event); |
1168 } else { | 1164 } else { |
1169 ui::MouseEvent mapped_event(*event->AsPointerEvent()); | 1165 ui::MouseEvent mapped_event(*event->AsPointerEvent()); |
1166 ui::Event::DispatcherApi dispatch_helper(&mapped_event); | |
1167 dispatch_helper.set_target(window->GetWindow()); | |
1170 host->SendEventToProcessor(&mapped_event); | 1168 host->SendEventToProcessor(&mapped_event); |
1171 } | 1169 } |
1172 } else if (event->IsTouchPointerEvent()) { | 1170 } else if (event->IsTouchPointerEvent()) { |
1173 ui::TouchEvent mapped_event(*event->AsPointerEvent()); | 1171 ui::TouchEvent mapped_event(*event->AsPointerEvent()); |
1172 ui::Event::DispatcherApi dispatch_helper(&mapped_event); | |
1173 dispatch_helper.set_target(window->GetWindow()); | |
1174 host->SendEventToProcessor(&mapped_event); | 1174 host->SendEventToProcessor(&mapped_event); |
1175 } else { | 1175 } else { |
1176 ui::Event::DispatcherApi dispatch_helper(event.get()); | |
1177 dispatch_helper.set_target(window->GetWindow()); | |
1176 host->SendEventToProcessor(event.get()); | 1178 host->SendEventToProcessor(event.get()); |
sadrul
2017/02/08 00:24:38
This should go into some helper function, e.g. Win
riajiang
2017/02/11 00:43:39
Done.
| |
1177 } | 1179 } |
1178 ack_handler.set_handled(event->handled()); | 1180 ack_handler.set_handled(event->handled()); |
1179 } | 1181 } |
1180 | 1182 |
1181 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 1183 void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
1182 uint32_t window_id) { | 1184 uint32_t window_id) { |
1183 DCHECK(event); | 1185 DCHECK(event); |
1184 DCHECK(event->IsPointerEvent()); | 1186 DCHECK(event->IsPointerEvent()); |
1185 if (!has_pointer_watcher_) | 1187 if (!has_pointer_watcher_) |
1186 return; | 1188 return; |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1820 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1819 this, capture_synchronizer_.get(), window)); | 1821 this, capture_synchronizer_.get(), window)); |
1820 } | 1822 } |
1821 | 1823 |
1822 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1824 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1823 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1825 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1824 this, focus_synchronizer_.get(), window)); | 1826 this, focus_synchronizer_.get(), window)); |
1825 } | 1827 } |
1826 | 1828 |
1827 } // namespace aura | 1829 } // namespace aura |
OLD | NEW |