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 "components/view_manager/connection_manager.h" | 5 #include "components/view_manager/connection_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
10 #include "components/view_manager/connection_manager_delegate.h" | 10 #include "components/view_manager/connection_manager_delegate.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 ConnectionManager::ScopedChange::~ScopedChange() { | 109 ConnectionManager::ScopedChange::~ScopedChange() { |
110 connection_manager_->FinishChange(); | 110 connection_manager_->FinishChange(); |
111 } | 111 } |
112 | 112 |
113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, | 113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, |
114 scoped_ptr<DisplayManager> display_manager) | 114 scoped_ptr<DisplayManager> display_manager) |
115 : delegate_(delegate), | 115 : delegate_(delegate), |
116 window_manager_client_connection_(nullptr), | 116 window_manager_client_connection_(nullptr), |
117 next_connection_id_(1), | 117 next_connection_id_(1), |
| 118 event_dispatcher_(this), |
118 display_manager_(display_manager.Pass()), | 119 display_manager_(display_manager.Pass()), |
119 root_(CreateServerView(RootViewId())), | 120 root_(CreateServerView(RootViewId())), |
120 current_change_(nullptr), | 121 current_change_(nullptr), |
121 in_destructor_(false), | 122 in_destructor_(false), |
122 animation_runner_(base::TimeTicks::Now()), | 123 animation_runner_(base::TimeTicks::Now()), |
123 event_dispatcher_(this), | |
124 event_dispatcher_binding_(&event_dispatcher_), | |
125 focus_controller_(new FocusController(this, root_.get())) { | 124 focus_controller_(new FocusController(this, root_.get())) { |
126 root_->SetBounds(gfx::Rect(800, 600)); | 125 root_->SetBounds(gfx::Rect(800, 600)); |
127 root_->SetVisible(true); | 126 root_->SetVisible(true); |
128 | 127 |
129 mojo::NativeViewportEventDispatcherPtr event_dispatcher_ptr; | 128 display_manager_->Init(this, &event_dispatcher_); |
130 event_dispatcher_binding_.Bind(GetProxy(&event_dispatcher_ptr)); | |
131 display_manager_->Init(this, event_dispatcher_ptr.Pass()); | |
132 } | 129 } |
133 | 130 |
134 ConnectionManager::~ConnectionManager() { | 131 ConnectionManager::~ConnectionManager() { |
135 in_destructor_ = true; | 132 in_destructor_ = true; |
136 | 133 |
137 // Deleting views will attempt to advance focus. When we're being destroyed | 134 // Deleting views will attempt to advance focus. When we're being destroyed |
138 // that is not necessary. Additionally |focus_controller_| needs to be | 135 // that is not necessary. Additionally |focus_controller_| needs to be |
139 // destroyed before |root_|. | 136 // destroyed before |root_|. |
140 focus_controller_.reset(); | 137 focus_controller_.reset(); |
141 | 138 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 this, &ConnectionManager::DoAnimation); | 302 this, &ConnectionManager::DoAnimation); |
306 } | 303 } |
307 ServerView* clone = CloneView(view, this); | 304 ServerView* clone = CloneView(view, this); |
308 CloneViewTree(view, clone, this); | 305 CloneViewTree(view, clone, this); |
309 view->parent()->Add(clone); | 306 view->parent()->Add(clone); |
310 view->parent()->Reorder(clone, view, mojo::ORDER_DIRECTION_ABOVE); | 307 view->parent()->Reorder(clone, view, mojo::ORDER_DIRECTION_ABOVE); |
311 return true; | 308 return true; |
312 } | 309 } |
313 | 310 |
314 void ConnectionManager::ProcessEvent(mojo::EventPtr event) { | 311 void ConnectionManager::ProcessEvent(mojo::EventPtr event) { |
315 event_dispatcher_.OnEvent(event.Pass(), EventDispatcher::OnEventCallback()); | 312 event_dispatcher_.OnEvent(event.Pass(), base::Bind(&base::DoNothing)); |
316 } | 313 } |
317 | 314 |
318 void ConnectionManager::DispatchInputEventToView(const ServerView* view, | 315 void ConnectionManager::DispatchInputEventToView(const ServerView* view, |
319 mojo::EventPtr event) { | 316 mojo::EventPtr event) { |
320 // If the view is an embed root, forward to the embedded view, not the owner. | 317 // If the view is an embed root, forward to the embedded view, not the owner. |
321 ViewManagerServiceImpl* connection = GetConnectionWithRoot(view->id()); | 318 ViewManagerServiceImpl* connection = GetConnectionWithRoot(view->id()); |
322 if (!connection) | 319 if (!connection) |
323 connection = GetConnection(view->id().connection_id); | 320 connection = GetConnection(view->id().connection_id); |
324 CHECK(connection); | 321 CHECK(connection); |
325 connection->client()->OnViewInputEvent(ViewIdToTransportId(view->id()), | 322 connection->client()->OnViewInputEvent(ViewIdToTransportId(view->id()), |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 if (wm_connection != owning_connection_old && | 612 if (wm_connection != owning_connection_old && |
616 wm_connection != embedded_connection_old && | 613 wm_connection != embedded_connection_old && |
617 wm_connection != owning_connection_new && | 614 wm_connection != owning_connection_new && |
618 wm_connection != embedded_connection_new) { | 615 wm_connection != embedded_connection_new) { |
619 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); | 616 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); |
620 } | 617 } |
621 } | 618 } |
622 } | 619 } |
623 | 620 |
624 } // namespace view_manager | 621 } // namespace view_manager |
OLD | NEW |