| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Set the |target| to be the target window of this |event| and send it to | 179 // Set the |target| to be the target window of this |event| and send it to |
| 180 // the EventSink. | 180 // the EventSink. |
| 181 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { | 181 void DispatchEventToTarget(ui::Event* event, WindowMus* target) { |
| 182 ui::Event::DispatcherApi dispatch_helper(event); | 182 ui::Event::DispatcherApi dispatch_helper(event); |
| 183 dispatch_helper.set_target(target->GetWindow()); | 183 dispatch_helper.set_target(target->GetWindow()); |
| 184 GetWindowTreeHostMus(target)->SendEventToSink(event); | 184 GetWindowTreeHostMus(target)->SendEventToSink(event); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void IMEAckCallback(std::unique_ptr<EventResultCallback> result_callback, |
| 188 bool handled) { |
| 189 result_callback->Run(handled ? ui::mojom::EventResult::HANDLED |
| 190 : ui::mojom::EventResult::UNHANDLED); |
| 191 } |
| 192 |
| 187 } // namespace | 193 } // namespace |
| 188 | 194 |
| 189 WindowTreeClient::WindowTreeClient( | 195 WindowTreeClient::WindowTreeClient( |
| 190 service_manager::Connector* connector, | 196 service_manager::Connector* connector, |
| 191 WindowTreeClientDelegate* delegate, | 197 WindowTreeClientDelegate* delegate, |
| 192 WindowManagerDelegate* window_manager_delegate, | 198 WindowManagerDelegate* window_manager_delegate, |
| 193 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, | 199 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, |
| 194 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 200 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 195 bool create_discardable_memory) | 201 bool create_discardable_memory) |
| 196 : connector_(connector), | 202 : connector_(connector), |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 DCHECK(event); | 1234 DCHECK(event); |
| 1229 | 1235 |
| 1230 WindowMus* window = GetWindowByServerId(window_id); // May be null. | 1236 WindowMus* window = GetWindowByServerId(window_id); // May be null. |
| 1231 | 1237 |
| 1232 if (event->IsKeyEvent()) { | 1238 if (event->IsKeyEvent()) { |
| 1233 DCHECK(!matches_pointer_watcher); // PointerWatcher isn't for key events. | 1239 DCHECK(!matches_pointer_watcher); // PointerWatcher isn't for key events. |
| 1234 if (!window || !window->GetWindow()->GetHost()) { | 1240 if (!window || !window->GetWindow()->GetHost()) { |
| 1235 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); | 1241 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); |
| 1236 return; | 1242 return; |
| 1237 } | 1243 } |
| 1238 InputMethodMus* input_method = GetWindowTreeHostMus(window)->input_method(); | 1244 GetWindowTreeHostMus(window)->DispatchEventToInputMethod( |
| 1239 input_method->DispatchKeyEvent(event->AsKeyEvent(), | 1245 event->AsKeyEvent(), |
| 1240 CreateEventResultCallback(event_id)); | 1246 base::MakeUnique<InputMethodMus::AckCallback>(base::Bind( |
| 1247 &IMEAckCallback, Passed(CreateEventResultCallback(event_id))))); |
| 1241 return; | 1248 return; |
| 1242 } | 1249 } |
| 1243 | 1250 |
| 1244 if (matches_pointer_watcher && has_pointer_watcher_) { | 1251 if (matches_pointer_watcher && has_pointer_watcher_) { |
| 1245 DCHECK(event->IsPointerEvent()); | 1252 DCHECK(event->IsPointerEvent()); |
| 1246 std::unique_ptr<ui::Event> event_in_dip(ui::Event::Clone(*event)); | 1253 std::unique_ptr<ui::Event> event_in_dip(ui::Event::Clone(*event)); |
| 1247 ConvertEventLocationToDip(display_id, event_in_dip->AsLocatedEvent()); | 1254 ConvertEventLocationToDip(display_id, event_in_dip->AsLocatedEvent()); |
| 1248 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), | 1255 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), |
| 1249 window ? window->GetWindow() : nullptr); | 1256 window ? window->GetWindow() : nullptr); |
| 1250 } | 1257 } |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1977 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1971 this, capture_synchronizer_.get(), window)); | 1978 this, capture_synchronizer_.get(), window)); |
| 1972 } | 1979 } |
| 1973 | 1980 |
| 1974 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1981 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1975 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1982 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1976 this, focus_synchronizer_.get(), window)); | 1983 this, focus_synchronizer_.get(), window)); |
| 1977 } | 1984 } |
| 1978 | 1985 |
| 1979 } // namespace aura | 1986 } // namespace aura |
| OLD | NEW |