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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
49 // WindowManagerApp, public: | 49 // WindowManagerApp, public: |
50 | 50 |
51 WindowManagerApp::WindowManagerApp( | 51 WindowManagerApp::WindowManagerApp( |
52 ViewManagerDelegate* view_manager_delegate, | 52 ViewManagerDelegate* view_manager_delegate, |
53 WindowManagerDelegate* window_manager_delegate) | 53 WindowManagerDelegate* window_manager_delegate) |
54 : shell_(nullptr), | 54 : shell_(nullptr), |
55 native_viewport_event_dispatcher_factory_(this), | 55 native_viewport_event_dispatcher_factory_(this), |
56 wrapped_view_manager_delegate_(view_manager_delegate), | 56 wrapped_view_manager_delegate_(view_manager_delegate), |
57 window_manager_delegate_(window_manager_delegate), | 57 window_manager_delegate_(window_manager_delegate), |
58 root_(nullptr) { | 58 root_(nullptr), |
| 59 gesture_provider_(this) { |
59 } | 60 } |
60 | 61 |
61 WindowManagerApp::~WindowManagerApp() { | 62 WindowManagerApp::~WindowManagerApp() { |
62 STLDeleteElements(&connections_); | 63 STLDeleteElements(&connections_); |
63 } | 64 } |
64 | 65 |
65 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) { | 66 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) { |
66 DCHECK(connections_.find(connection) == connections_.end()); | 67 DCHECK(connections_.find(connection) == connections_.end()); |
67 connections_.insert(connection); | 68 connections_.insert(connection); |
68 } | 69 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 213 |
213 View* view = static_cast<ViewTarget*>(event->target())->view(); | 214 View* view = static_cast<ViewTarget*>(event->target())->view(); |
214 if (!view) | 215 if (!view) |
215 return; | 216 return; |
216 | 217 |
217 if (focus_controller_) | 218 if (focus_controller_) |
218 focus_controller_->OnEvent(event); | 219 focus_controller_->OnEvent(event); |
219 | 220 |
220 window_manager_client_->DispatchInputEventToView(view->id(), | 221 window_manager_client_->DispatchInputEventToView(view->id(), |
221 mojo::Event::From(*event)); | 222 mojo::Event::From(*event)); |
| 223 |
| 224 if (event->IsTouchEvent()) { |
| 225 gesture_provider_.OnTouchEvent(*static_cast<ui::TouchEvent*>(event)); |
| 226 scoped_ptr<ScopedVector<ui::GestureEvent>> gestures( |
| 227 gesture_provider_.GetAndResetPendingGestures()); |
| 228 if (gestures) { |
| 229 for (auto& gesture : *gestures) { |
| 230 window_manager_client_->DispatchInputEventToView( |
| 231 view->id(), mojo::Event::From(*gesture)); |
| 232 } |
| 233 } |
| 234 gesture_provider_.OnTouchEventAck(false); |
| 235 } |
222 } | 236 } |
223 | 237 |
224 //////////////////////////////////////////////////////////////////////////////// | 238 //////////////////////////////////////////////////////////////////////////////// |
| 239 // WindowManagerApp, ui::GestureProviderImplClient implementation: |
| 240 |
| 241 void WindowManagerApp::OnGestureEvent(ui::GestureEvent* event) { |
| 242 DCHECK(!event->IsTouchEvent()); |
| 243 // TODO(abarth): Do we need to dispatch this |event|? |
| 244 } |
| 245 |
| 246 //////////////////////////////////////////////////////////////////////////////// |
225 // WindowManagerApp, mojo::FocusControllerObserver implementation: | 247 // WindowManagerApp, mojo::FocusControllerObserver implementation: |
226 | 248 |
227 void WindowManagerApp::OnViewFocused(View* gained_focus, | 249 void WindowManagerApp::OnViewFocused(View* gained_focus, |
228 View* lost_focus) { | 250 View* lost_focus) { |
229 for (Connections::const_iterator it = connections_.begin(); | 251 for (Connections::const_iterator it = connections_.begin(); |
230 it != connections_.end(); ++it) { | 252 it != connections_.end(); ++it) { |
231 (*it)->NotifyViewFocused(GetIdForView(gained_focus), | 253 (*it)->NotifyViewFocused(GetIdForView(gained_focus), |
232 GetIdForView(lost_focus)); | 254 GetIdForView(lost_focus)); |
233 } | 255 } |
234 } | 256 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 uint16_t connection_id, | 375 uint16_t connection_id, |
354 mojo::ScopedMessagePipeHandle window_manager_pipe) { | 376 mojo::ScopedMessagePipeHandle window_manager_pipe) { |
355 // TODO(sky): pass in |connection_id| for validation. | 377 // TODO(sky): pass in |connection_id| for validation. |
356 WindowManagerImpl* wm = new WindowManagerImpl(this, true); | 378 WindowManagerImpl* wm = new WindowManagerImpl(this, true); |
357 wm->Bind(window_manager_pipe.Pass()); | 379 wm->Bind(window_manager_pipe.Pass()); |
358 // WindowManagerImpl is deleted when the connection has an error, or from our | 380 // WindowManagerImpl is deleted when the connection has an error, or from our |
359 // destructor. | 381 // destructor. |
360 } | 382 } |
361 | 383 |
362 } // namespace window_manager | 384 } // namespace window_manager |
OLD | NEW |