| 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 "services/window_manager/window_manager_app.h" | 5 #include "services/window_manager/window_manager_app.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/converters/input_events/input_events_type_converters.h" | 10 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 11 #include "mojo/public/cpp/application/application_connection.h" | 11 #include "mojo/public/cpp/application/application_connection.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | 12 #include "mojo/public/cpp/application/application_impl.h" |
| 13 #include "mojo/public/interfaces/application/shell.mojom.h" | 13 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 14 #include "mojo/services/view_manager/public/cpp/view.h" | 14 #include "mojo/services/view_manager/public/cpp/view.h" |
| 15 #include "mojo/services/view_manager/public/cpp/view_manager.h" | 15 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
| 16 #include "services/window_manager/capture_controller.h" | 16 #include "services/window_manager/capture_controller.h" |
| 17 #include "services/window_manager/focus_controller.h" | 17 #include "services/window_manager/focus_controller.h" |
| 18 #include "services/window_manager/focus_rules.h" | 18 #include "services/window_manager/focus_rules.h" |
| 19 #include "services/window_manager/hit_test.h" | 19 #include "services/window_manager/hit_test.h" |
| 20 #include "services/window_manager/view_event_dispatcher.h" | 20 #include "services/window_manager/view_event_dispatcher.h" |
| 21 #include "services/window_manager/view_target.h" | 21 #include "services/window_manager/view_target.h" |
| 22 #include "services/window_manager/view_targeter.h" | 22 #include "services/window_manager/view_targeter.h" |
| 23 #include "services/window_manager/window_manager_delegate.h" | 23 #include "services/window_manager/window_manager_delegate.h" |
| 24 #include "ui/events/gestures/gesture_recognizer.h" | |
| 25 | 24 |
| 26 using mojo::ApplicationConnection; | 25 using mojo::ApplicationConnection; |
| 27 using mojo::Id; | 26 using mojo::Id; |
| 28 using mojo::ServiceProvider; | 27 using mojo::ServiceProvider; |
| 29 using mojo::View; | 28 using mojo::View; |
| 30 using mojo::WindowManager; | 29 using mojo::WindowManager; |
| 31 | 30 |
| 32 namespace window_manager { | 31 namespace window_manager { |
| 33 | 32 |
| 34 namespace { | 33 namespace { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 View* view = cached_view_manager->GetViewById(*it); | 67 View* view = cached_view_manager->GetViewById(*it); |
| 69 if (view && view == root_) | 68 if (view && view == root_) |
| 70 root_ = nullptr; | 69 root_ = nullptr; |
| 71 if (view) | 70 if (view) |
| 72 view->RemoveObserver(this); | 71 view->RemoveObserver(this); |
| 73 } | 72 } |
| 74 registered_view_id_set_.clear(); | 73 registered_view_id_set_.clear(); |
| 75 DCHECK(!root_); | 74 DCHECK(!root_); |
| 76 | 75 |
| 77 STLDeleteElements(&connections_); | 76 STLDeleteElements(&connections_); |
| 78 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); | |
| 79 } | 77 } |
| 80 | 78 |
| 81 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) { | 79 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) { |
| 82 DCHECK(connections_.find(connection) == connections_.end()); | 80 DCHECK(connections_.find(connection) == connections_.end()); |
| 83 connections_.insert(connection); | 81 connections_.insert(connection); |
| 84 } | 82 } |
| 85 | 83 |
| 86 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) { | 84 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) { |
| 87 DCHECK(connections_.find(connection) != connections_.end()); | 85 DCHECK(connections_.find(connection) != connections_.end()); |
| 88 connections_.erase(connection); | 86 connections_.erase(connection); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if (!window_manager_client_) | 228 if (!window_manager_client_) |
| 231 return; | 229 return; |
| 232 | 230 |
| 233 View* view = static_cast<ViewTarget*>(event->target())->view(); | 231 View* view = static_cast<ViewTarget*>(event->target())->view(); |
| 234 if (!view) | 232 if (!view) |
| 235 return; | 233 return; |
| 236 | 234 |
| 237 if (focus_controller_) | 235 if (focus_controller_) |
| 238 focus_controller_->OnEvent(event); | 236 focus_controller_->OnEvent(event); |
| 239 | 237 |
| 240 auto gesture_recognizer = ui::GestureRecognizer::Get(); | |
| 241 ui::TouchEvent* touch_event = | |
| 242 event->IsTouchEvent() ? static_cast<ui::TouchEvent*>(event) : nullptr; | |
| 243 | |
| 244 if (touch_event) | |
| 245 gesture_recognizer->ProcessTouchEventPreDispatch(*touch_event, this); | |
| 246 | |
| 247 window_manager_client_->DispatchInputEventToView(view->id(), | 238 window_manager_client_->DispatchInputEventToView(view->id(), |
| 248 mojo::Event::From(*event)); | 239 mojo::Event::From(*event)); |
| 249 | |
| 250 if (touch_event) { | |
| 251 scoped_ptr<ScopedVector<ui::GestureEvent>> gestures( | |
| 252 gesture_recognizer->ProcessTouchEventPostDispatch( | |
| 253 *touch_event, ui::ER_UNHANDLED, this)); | |
| 254 | |
| 255 if (gestures) { | |
| 256 for (auto& gesture : *gestures) { | |
| 257 window_manager_client_->DispatchInputEventToView( | |
| 258 view->id(), mojo::Event::From(*gesture)); | |
| 259 } | |
| 260 } | |
| 261 } | |
| 262 } | 240 } |
| 263 | 241 |
| 264 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
| 265 // WindowManagerApp, mojo::FocusControllerObserver implementation: | 243 // WindowManagerApp, mojo::FocusControllerObserver implementation: |
| 266 | 244 |
| 267 void WindowManagerApp::OnFocused(View* gained_focus) { | 245 void WindowManagerApp::OnFocused(View* gained_focus) { |
| 268 for (Connections::const_iterator it = connections_.begin(); | 246 for (Connections::const_iterator it = connections_.begin(); |
| 269 it != connections_.end(); ++it) { | 247 it != connections_.end(); ++it) { |
| 270 (*it)->NotifyViewFocused(GetIdForView(gained_focus)); | 248 (*it)->NotifyViewFocused(GetIdForView(gained_focus)); |
| 271 } | 249 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 uint16_t connection_id, | 365 uint16_t connection_id, |
| 388 mojo::ScopedMessagePipeHandle window_manager_pipe) { | 366 mojo::ScopedMessagePipeHandle window_manager_pipe) { |
| 389 // TODO(sky): pass in |connection_id| for validation. | 367 // TODO(sky): pass in |connection_id| for validation. |
| 390 WindowManagerImpl* wm = new WindowManagerImpl(this, true); | 368 WindowManagerImpl* wm = new WindowManagerImpl(this, true); |
| 391 wm->Bind(window_manager_pipe.Pass()); | 369 wm->Bind(window_manager_pipe.Pass()); |
| 392 // WindowManagerImpl is deleted when the connection has an error, or from our | 370 // WindowManagerImpl is deleted when the connection has an error, or from our |
| 393 // destructor. | 371 // destructor. |
| 394 } | 372 } |
| 395 | 373 |
| 396 } // namespace window_manager | 374 } // namespace window_manager |
| OLD | NEW |