OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mus/view_tree_host_impl.h" | 5 #include "components/mus/view_tree_host_impl.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/mus/connection_manager.h" | 8 #include "components/mus/connection_manager.h" |
9 #include "components/mus/display_manager.h" | 9 #include "components/mus/display_manager.h" |
10 #include "components/mus/focus_controller.h" | 10 #include "components/mus/focus_controller.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 const scoped_refptr<GpuState>& gpu_state, | 24 const scoped_refptr<GpuState>& gpu_state, |
25 const scoped_refptr<SurfacesState>& surfaces_state) | 25 const scoped_refptr<SurfacesState>& surfaces_state) |
26 : delegate_(nullptr), | 26 : delegate_(nullptr), |
27 connection_manager_(connection_manager), | 27 connection_manager_(connection_manager), |
28 client_(client.Pass()), | 28 client_(client.Pass()), |
29 event_dispatcher_(this), | 29 event_dispatcher_(this), |
30 display_manager_(DisplayManager::Create(is_headless, | 30 display_manager_(DisplayManager::Create(is_headless, |
31 app_impl, | 31 app_impl, |
32 gpu_state, | 32 gpu_state, |
33 surfaces_state)), | 33 surfaces_state)), |
34 focus_controller_(new FocusController(this)) { | 34 focus_controller_(new FocusController(this)), |
| 35 captured_view_(nullptr) { |
35 display_manager_->Init(this); | 36 display_manager_->Init(this); |
36 if (client_) { | 37 if (client_) { |
37 client_.set_connection_error_handler( | 38 client_.set_connection_error_handler( |
38 base::Bind(&ViewTreeHostImpl::OnClientClosed, base::Unretained(this))); | 39 base::Bind(&ViewTreeHostImpl::OnClientClosed, base::Unretained(this))); |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 ViewTreeHostImpl::~ViewTreeHostImpl() {} | 43 ViewTreeHostImpl::~ViewTreeHostImpl() {} |
43 | 44 |
44 void ViewTreeHostImpl::Init(ViewTreeHostDelegate* delegate) { | 45 void ViewTreeHostImpl::Init(ViewTreeHostDelegate* delegate) { |
(...skipping 16 matching lines...) Expand all Loading... |
61 display_manager_->SchedulePaint(view, bounds); | 62 display_manager_->SchedulePaint(view, bounds); |
62 return true; | 63 return true; |
63 } | 64 } |
64 return false; | 65 return false; |
65 } | 66 } |
66 | 67 |
67 const mojo::ViewportMetrics& ViewTreeHostImpl::GetViewportMetrics() const { | 68 const mojo::ViewportMetrics& ViewTreeHostImpl::GetViewportMetrics() const { |
68 return display_manager_->GetViewportMetrics(); | 69 return display_manager_->GetViewportMetrics(); |
69 } | 70 } |
70 | 71 |
| 72 void ViewTreeHostImpl::SetCapture(ServerView* view) { |
| 73 if (captured_view_) { |
| 74 ViewTreeImpl* connection = |
| 75 connection_manager_->GetConnection(captured_view_->id().connection_id); |
| 76 if (connection) { |
| 77 connection->ProcessLostCapture(captured_view_); |
| 78 } |
| 79 } |
| 80 captured_view_ = view; |
| 81 if (captured_view_) |
| 82 display_manager_->SetCapture(); |
| 83 } |
| 84 |
71 void ViewTreeHostImpl::SetFocusedView(ServerView* new_focused_view) { | 85 void ViewTreeHostImpl::SetFocusedView(ServerView* new_focused_view) { |
72 ServerView* old_focused_view = focus_controller_->GetFocusedView(); | 86 ServerView* old_focused_view = focus_controller_->GetFocusedView(); |
73 if (old_focused_view == new_focused_view) | 87 if (old_focused_view == new_focused_view) |
74 return; | 88 return; |
75 DCHECK(root_view()->Contains(new_focused_view)); | 89 DCHECK(root_view()->Contains(new_focused_view)); |
76 focus_controller_->SetFocusedView(new_focused_view); | 90 focus_controller_->SetFocusedView(new_focused_view); |
77 // TODO(beng): have the FocusController notify us via FocusControllerDelegate. | 91 // TODO(beng): have the FocusController notify us via FocusControllerDelegate. |
78 OnFocusChanged(old_focused_view, new_focused_view); | 92 OnFocusChanged(old_focused_view, new_focused_view); |
79 } | 93 } |
80 | 94 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 161 } |
148 | 162 |
149 ServerView* ViewTreeHostImpl::GetRootView() { | 163 ServerView* ViewTreeHostImpl::GetRootView() { |
150 return root_.get(); | 164 return root_.get(); |
151 } | 165 } |
152 | 166 |
153 void ViewTreeHostImpl::OnEvent(mojo::EventPtr event) { | 167 void ViewTreeHostImpl::OnEvent(mojo::EventPtr event) { |
154 event_dispatcher_.OnEvent(event.Pass()); | 168 event_dispatcher_.OnEvent(event.Pass()); |
155 } | 169 } |
156 | 170 |
| 171 void ViewTreeHostImpl::OnLostCapture() { |
| 172 SetCapture(nullptr); |
| 173 } |
| 174 |
157 void ViewTreeHostImpl::OnDisplayClosed() { | 175 void ViewTreeHostImpl::OnDisplayClosed() { |
158 if (delegate_) | 176 if (delegate_) |
159 delegate_->OnDisplayClosed(); | 177 delegate_->OnDisplayClosed(); |
160 } | 178 } |
161 | 179 |
162 void ViewTreeHostImpl::OnViewportMetricsChanged( | 180 void ViewTreeHostImpl::OnViewportMetricsChanged( |
163 const mojo::ViewportMetrics& old_metrics, | 181 const mojo::ViewportMetrics& old_metrics, |
164 const mojo::ViewportMetrics& new_metrics) { | 182 const mojo::ViewportMetrics& new_metrics) { |
165 if (!root_) { | 183 if (!root_) { |
166 root_.reset(connection_manager_->CreateServerView( | 184 root_.reset(connection_manager_->CreateServerView( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 root_tree != embedded_connection_old && | 250 root_tree != embedded_connection_old && |
233 root_tree != owning_connection_new && | 251 root_tree != owning_connection_new && |
234 root_tree != embedded_connection_new) { | 252 root_tree != embedded_connection_new) { |
235 root_tree->ProcessFocusChanged(old_focused_view, new_focused_view); | 253 root_tree->ProcessFocusChanged(old_focused_view, new_focused_view); |
236 } | 254 } |
237 | 255 |
238 UpdateTextInputState(new_focused_view, new_focused_view->text_input_state()); | 256 UpdateTextInputState(new_focused_view, new_focused_view->text_input_state()); |
239 } | 257 } |
240 | 258 |
241 } // namespace mus | 259 } // namespace mus |
OLD | NEW |