Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: components/mus/ws/view_tree_host_impl.cc

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/view_tree_host_impl.h ('k') | components/mus/ws/view_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ws/view_tree_host_impl.h" 5 #include "components/mus/ws/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/public/cpp/types.h" 8 #include "components/mus/public/cpp/types.h"
9 #include "components/mus/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
11 #include "components/mus/ws/focus_controller.h" 11 #include "components/mus/ws/focus_controller.h"
12 #include "components/mus/ws/view_tree_host_delegate.h" 12 #include "components/mus/ws/view_tree_host_delegate.h"
13 #include "components/mus/ws/view_tree_impl.h" 13 #include "components/mus/ws/view_tree_impl.h"
14 #include "mojo/common/common_type_converters.h" 14 #include "mojo/common/common_type_converters.h"
15 #include "mojo/converters/geometry/geometry_type_converters.h" 15 #include "mojo/converters/geometry/geometry_type_converters.h"
16 16
17 namespace mus { 17 namespace mus {
18 18
19 ViewTreeHostImpl::ViewTreeHostImpl( 19 ViewTreeHostImpl::ViewTreeHostImpl(
20 mojo::ViewTreeHostClientPtr client, 20 mojom::WindowTreeHostClientPtr client,
21 ConnectionManager* connection_manager, 21 ConnectionManager* connection_manager,
22 mojo::ApplicationImpl* app_impl, 22 mojo::ApplicationImpl* app_impl,
23 const scoped_refptr<GpuState>& gpu_state, 23 const scoped_refptr<GpuState>& gpu_state,
24 const scoped_refptr<SurfacesState>& surfaces_state) 24 const scoped_refptr<SurfacesState>& surfaces_state)
25 : delegate_(nullptr), 25 : delegate_(nullptr),
26 connection_manager_(connection_manager), 26 connection_manager_(connection_manager),
27 client_(client.Pass()), 27 client_(client.Pass()),
28 event_dispatcher_(this), 28 event_dispatcher_(this),
29 display_manager_(DisplayManager::Create(app_impl, 29 display_manager_(
30 gpu_state, 30 DisplayManager::Create(app_impl, gpu_state, surfaces_state)),
31 surfaces_state)),
32 focus_controller_(new FocusController(this)) { 31 focus_controller_(new FocusController(this)) {
33 display_manager_->Init(this); 32 display_manager_->Init(this);
34 if (client_) { 33 if (client_) {
35 client_.set_connection_error_handler( 34 client_.set_connection_error_handler(
36 base::Bind(&ViewTreeHostImpl::OnClientClosed, base::Unretained(this))); 35 base::Bind(&ViewTreeHostImpl::OnClientClosed, base::Unretained(this)));
37 } 36 }
38 } 37 }
39 38
40 ViewTreeHostImpl::~ViewTreeHostImpl() {} 39 ViewTreeHostImpl::~ViewTreeHostImpl() {}
41 40
42 void ViewTreeHostImpl::Init(ViewTreeHostDelegate* delegate) { 41 void ViewTreeHostImpl::Init(ViewTreeHostDelegate* delegate) {
43 delegate_ = delegate; 42 delegate_ = delegate;
44 if (delegate_ && root_) 43 if (delegate_ && root_)
45 delegate_->OnDisplayInitialized(); 44 delegate_->OnDisplayInitialized();
46 } 45 }
47 46
48 ViewTreeImpl* ViewTreeHostImpl::GetViewTree() { 47 ViewTreeImpl* ViewTreeHostImpl::GetWindowTree() {
49 return delegate_ ? delegate_->GetViewTree() : nullptr; 48 return delegate_ ? delegate_->GetWindowTree() : nullptr;
50 } 49 }
51 50
52 bool ViewTreeHostImpl::IsViewAttachedToRoot(const ServerView* view) const { 51 bool ViewTreeHostImpl::IsViewAttachedToRoot(const ServerView* view) const {
53 return root_->Contains(view) && view != root_.get(); 52 return root_->Contains(view) && view != root_.get();
54 } 53 }
55 54
56 bool ViewTreeHostImpl::SchedulePaintIfInViewport(const ServerView* view, 55 bool ViewTreeHostImpl::SchedulePaintIfInViewport(const ServerView* view,
57 const gfx::Rect& bounds) { 56 const gfx::Rect& bounds) {
58 if (root_->Contains(view)) { 57 if (root_->Contains(view)) {
59 display_manager_->SchedulePaint(view, bounds); 58 display_manager_->SchedulePaint(view, bounds);
60 return true; 59 return true;
61 } 60 }
62 return false; 61 return false;
63 } 62 }
64 63
65 const mojo::ViewportMetrics& ViewTreeHostImpl::GetViewportMetrics() const { 64 const mojom::ViewportMetrics& ViewTreeHostImpl::GetViewportMetrics() const {
66 return display_manager_->GetViewportMetrics(); 65 return display_manager_->GetViewportMetrics();
67 } 66 }
68 67
69 void ViewTreeHostImpl::SetFocusedView(ServerView* new_focused_view) { 68 void ViewTreeHostImpl::SetFocusedView(ServerView* new_focused_view) {
70 ServerView* old_focused_view = focus_controller_->GetFocusedView(); 69 ServerView* old_focused_view = focus_controller_->GetFocusedView();
71 if (old_focused_view == new_focused_view) 70 if (old_focused_view == new_focused_view)
72 return; 71 return;
73 DCHECK(root_view()->Contains(new_focused_view)); 72 DCHECK(root_view()->Contains(new_focused_view));
74 focus_controller_->SetFocusedView(new_focused_view); 73 focus_controller_->SetFocusedView(new_focused_view);
75 // TODO(beng): have the FocusController notify us via FocusControllerDelegate. 74 // TODO(beng): have the FocusController notify us via FocusControllerDelegate.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void ViewTreeHostImpl::OnEvent(mojo::EventPtr event) { 149 void ViewTreeHostImpl::OnEvent(mojo::EventPtr event) {
151 event_dispatcher_.OnEvent(event.Pass()); 150 event_dispatcher_.OnEvent(event.Pass());
152 } 151 }
153 152
154 void ViewTreeHostImpl::OnDisplayClosed() { 153 void ViewTreeHostImpl::OnDisplayClosed() {
155 if (delegate_) 154 if (delegate_)
156 delegate_->OnDisplayClosed(); 155 delegate_->OnDisplayClosed();
157 } 156 }
158 157
159 void ViewTreeHostImpl::OnViewportMetricsChanged( 158 void ViewTreeHostImpl::OnViewportMetricsChanged(
160 const mojo::ViewportMetrics& old_metrics, 159 const mojom::ViewportMetrics& old_metrics,
161 const mojo::ViewportMetrics& new_metrics) { 160 const mojom::ViewportMetrics& new_metrics) {
162 if (!root_) { 161 if (!root_) {
163 root_.reset(connection_manager_->CreateServerView( 162 root_.reset(connection_manager_->CreateServerView(
164 RootViewId(connection_manager_->GetAndAdvanceNextHostId()))); 163 RootViewId(connection_manager_->GetAndAdvanceNextHostId())));
165 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); 164 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>()));
166 root_->SetVisible(true); 165 root_->SetVisible(true);
167 if (delegate_) 166 if (delegate_)
168 delegate_->OnDisplayInitialized(); 167 delegate_->OnDisplayInitialized();
169 } else { 168 } else {
170 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); 169 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>()));
171 } 170 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (embedded_connection_new && 220 if (embedded_connection_new &&
222 embedded_connection_new != owning_connection_old && 221 embedded_connection_new != owning_connection_old &&
223 embedded_connection_new != embedded_connection_old) { 222 embedded_connection_new != embedded_connection_old) {
224 DCHECK_NE(owning_connection_new, embedded_connection_new); 223 DCHECK_NE(owning_connection_new, embedded_connection_new);
225 embedded_connection_new->ProcessFocusChanged(old_focused_view, 224 embedded_connection_new->ProcessFocusChanged(old_focused_view,
226 new_focused_view); 225 new_focused_view);
227 } 226 }
228 } 227 }
229 228
230 // Ensure that we always notify the root connection of a focus change. 229 // Ensure that we always notify the root connection of a focus change.
231 ViewTreeImpl* root_tree = GetViewTree(); 230 ViewTreeImpl* root_tree = GetWindowTree();
232 if (root_tree != owning_connection_old && 231 if (root_tree != owning_connection_old &&
233 root_tree != embedded_connection_old && 232 root_tree != embedded_connection_old &&
234 root_tree != owning_connection_new && 233 root_tree != owning_connection_new &&
235 root_tree != embedded_connection_new) { 234 root_tree != embedded_connection_new) {
236 root_tree->ProcessFocusChanged(old_focused_view, new_focused_view); 235 root_tree->ProcessFocusChanged(old_focused_view, new_focused_view);
237 } 236 }
238 237
239 UpdateTextInputState(new_focused_view, new_focused_view->text_input_state()); 238 UpdateTextInputState(new_focused_view, new_focused_view->text_input_state());
240 } 239 }
241 240
242 } // namespace mus 241 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/view_tree_host_impl.h ('k') | components/mus/ws/view_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698