| 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/mus/public/cpp/lib/window_tree_client_impl.h" | 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" |
| 6 | 6 |
| 7 #include "components/mus/public/cpp/lib/window_private.h" | 7 #include "components/mus/public/cpp/lib/window_private.h" |
| 8 #include "components/mus/public/cpp/util.h" | 8 #include "components/mus/public/cpp/util.h" |
| 9 #include "components/mus/public/cpp/window_observer.h" | 9 #include "components/mus/public/cpp/window_observer.h" |
| 10 #include "components/mus/public/cpp/window_tree_connection.h" | 10 #include "components/mus/public/cpp/window_tree_connection.h" |
| 11 #include "components/mus/public/cpp/window_tree_delegate.h" | 11 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 12 #include "mojo/application/public/cpp/application_impl.h" | 12 #include "mojo/application/public/cpp/application_impl.h" |
| 13 #include "mojo/application/public/cpp/connect.h" | 13 #include "mojo/application/public/cpp/connect.h" |
| 14 #include "mojo/application/public/cpp/service_provider_impl.h" | 14 #include "mojo/application/public/cpp/service_provider_impl.h" |
| 15 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 15 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 16 | 16 |
| 17 namespace mus { | 17 namespace mus { |
| 18 | 18 |
| 19 Id MakeTransportId(ConnectionSpecificId connection_id, | 19 Id MakeTransportId(ConnectionSpecificId connection_id, |
| 20 ConnectionSpecificId local_id) { | 20 ConnectionSpecificId local_id) { |
| 21 return (connection_id << 16) | local_id; | 21 return (connection_id << 16) | local_id; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // Helper called to construct a local window object from transport data. | 24 // Helper called to construct a local window object from transport data. |
| 25 Window* AddWindowToConnection(WindowTreeClientImpl* client, | 25 Window* AddWindowToConnection(WindowTreeClientImpl* client, |
| 26 Window* parent, | 26 Window* parent, |
| 27 const mojo::ViewDataPtr& window_data) { | 27 const mojom::WindowDataPtr& window_data) { |
| 28 // We don't use the cto that takes a WindowTreeConnection here, since it will | 28 // We don't use the cto that takes a WindowTreeConnection here, since it will |
| 29 // call back to the service and attempt to create a new view. | 29 // call back to the service and attempt to create a new view. |
| 30 Window* window = WindowPrivate::LocalCreate(); | 30 Window* window = WindowPrivate::LocalCreate(); |
| 31 WindowPrivate private_window(window); | 31 WindowPrivate private_window(window); |
| 32 private_window.set_connection(client); | 32 private_window.set_connection(client); |
| 33 private_window.set_id(window_data->view_id); | 33 private_window.set_id(window_data->window_id); |
| 34 private_window.set_visible(window_data->visible); | 34 private_window.set_visible(window_data->visible); |
| 35 private_window.set_drawn(window_data->drawn); | 35 private_window.set_drawn(window_data->drawn); |
| 36 private_window.LocalSetViewportMetrics(mojo::ViewportMetrics(), | 36 private_window.LocalSetViewportMetrics(mojom::ViewportMetrics(), |
| 37 *window_data->viewport_metrics); | 37 *window_data->viewport_metrics); |
| 38 private_window.set_properties( | 38 private_window.set_properties( |
| 39 window_data->properties | 39 window_data->properties |
| 40 .To<std::map<std::string, std::vector<uint8_t>>>()); | 40 .To<std::map<std::string, std::vector<uint8_t>>>()); |
| 41 client->AddWindow(window); | 41 client->AddWindow(window); |
| 42 private_window.LocalSetBounds(mojo::Rect(), *window_data->bounds); | 42 private_window.LocalSetBounds(mojo::Rect(), *window_data->bounds); |
| 43 if (parent) | 43 if (parent) |
| 44 WindowPrivate(parent).LocalAddChild(window); | 44 WindowPrivate(parent).LocalAddChild(window); |
| 45 return window; | 45 return window; |
| 46 } | 46 } |
| 47 | 47 |
| 48 Window* BuildWindowTree(WindowTreeClientImpl* client, | 48 Window* BuildWindowTree(WindowTreeClientImpl* client, |
| 49 const mojo::Array<mojo::ViewDataPtr>& windows, | 49 const mojo::Array<mojom::WindowDataPtr>& windows, |
| 50 Window* initial_parent) { | 50 Window* initial_parent) { |
| 51 std::vector<Window*> parents; | 51 std::vector<Window*> parents; |
| 52 Window* root = NULL; | 52 Window* root = NULL; |
| 53 Window* last_window = NULL; | 53 Window* last_window = NULL; |
| 54 if (initial_parent) | 54 if (initial_parent) |
| 55 parents.push_back(initial_parent); | 55 parents.push_back(initial_parent); |
| 56 for (size_t i = 0; i < windows.size(); ++i) { | 56 for (size_t i = 0; i < windows.size(); ++i) { |
| 57 if (last_window && windows[i]->parent_id == last_window->id()) { | 57 if (last_window && windows[i]->parent_id == last_window->id()) { |
| 58 parents.push_back(last_window); | 58 parents.push_back(last_window); |
| 59 } else if (!parents.empty()) { | 59 } else if (!parents.empty()) { |
| 60 while (parents.back()->id() != windows[i]->parent_id) | 60 while (parents.back()->id() != windows[i]->parent_id) |
| 61 parents.pop_back(); | 61 parents.pop_back(); |
| 62 } | 62 } |
| 63 Window* window = AddWindowToConnection( | 63 Window* window = AddWindowToConnection( |
| 64 client, !parents.empty() ? parents.back() : NULL, windows[i]); | 64 client, !parents.empty() ? parents.back() : NULL, windows[i]); |
| 65 if (!last_window) | 65 if (!last_window) |
| 66 root = window; | 66 root = window; |
| 67 last_window = window; | 67 last_window = window; |
| 68 } | 68 } |
| 69 return root; | 69 return root; |
| 70 } | 70 } |
| 71 | 71 |
| 72 WindowTreeConnection* WindowTreeConnection::Create( | 72 WindowTreeConnection* WindowTreeConnection::Create( |
| 73 WindowTreeDelegate* delegate, | 73 WindowTreeDelegate* delegate, |
| 74 mojo::InterfaceRequest<mojo::ViewTreeClient> request, | 74 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request, |
| 75 CreateType create_type) { | 75 CreateType create_type) { |
| 76 WindowTreeClientImpl* client = | 76 WindowTreeClientImpl* client = |
| 77 new WindowTreeClientImpl(delegate, request.Pass()); | 77 new WindowTreeClientImpl(delegate, request.Pass()); |
| 78 if (create_type == CreateType::WAIT_FOR_EMBED) | 78 if (create_type == CreateType::WAIT_FOR_EMBED) |
| 79 client->WaitForEmbed(); | 79 client->WaitForEmbed(); |
| 80 return client; | 80 return client; |
| 81 } | 81 } |
| 82 | 82 |
| 83 WindowTreeClientImpl::WindowTreeClientImpl( | 83 WindowTreeClientImpl::WindowTreeClientImpl( |
| 84 WindowTreeDelegate* delegate, | 84 WindowTreeDelegate* delegate, |
| 85 mojo::InterfaceRequest<mojo::ViewTreeClient> request) | 85 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) |
| 86 : connection_id_(0), | 86 : connection_id_(0), |
| 87 next_id_(1), | 87 next_id_(1), |
| 88 delegate_(delegate), | 88 delegate_(delegate), |
| 89 root_(nullptr), | 89 root_(nullptr), |
| 90 capture_window_(nullptr), | 90 capture_window_(nullptr), |
| 91 focused_window_(nullptr), | 91 focused_window_(nullptr), |
| 92 activated_window_(nullptr), | 92 activated_window_(nullptr), |
| 93 binding_(this, request.Pass()), | 93 binding_(this, request.Pass()), |
| 94 is_embed_root_(false), | 94 is_embed_root_(false), |
| 95 in_destructor_(false) {} | 95 in_destructor_(false) {} |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 void WindowTreeClientImpl::WaitForEmbed() { | 121 void WindowTreeClientImpl::WaitForEmbed() { |
| 122 DCHECK(!root_); | 122 DCHECK(!root_); |
| 123 // OnEmbed() is the first function called. | 123 // OnEmbed() is the first function called. |
| 124 binding_.WaitForIncomingMethodCall(); | 124 binding_.WaitForIncomingMethodCall(); |
| 125 // TODO(sky): deal with pipe being closed before we get OnEmbed(). | 125 // TODO(sky): deal with pipe being closed before we get OnEmbed(). |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WindowTreeClientImpl::DestroyWindow(Id window_id) { | 128 void WindowTreeClientImpl::DestroyWindow(Id window_id) { |
| 129 DCHECK(tree_); | 129 DCHECK(tree_); |
| 130 tree_->DeleteView(window_id, ActionCompletedCallback()); | 130 tree_->DeleteWindow(window_id, ActionCompletedCallback()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void WindowTreeClientImpl::AddChild(Id child_id, Id parent_id) { | 133 void WindowTreeClientImpl::AddChild(Id child_id, Id parent_id) { |
| 134 DCHECK(tree_); | 134 DCHECK(tree_); |
| 135 tree_->AddView(parent_id, child_id, ActionCompletedCallback()); | 135 tree_->AddWindow(parent_id, child_id, ActionCompletedCallback()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void WindowTreeClientImpl::RemoveChild(Id child_id, Id parent_id) { | 138 void WindowTreeClientImpl::RemoveChild(Id child_id, Id parent_id) { |
| 139 DCHECK(tree_); | 139 DCHECK(tree_); |
| 140 tree_->RemoveViewFromParent(child_id, ActionCompletedCallback()); | 140 tree_->RemoveWindowFromParent(child_id, ActionCompletedCallback()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WindowTreeClientImpl::Reorder(Id window_id, | 143 void WindowTreeClientImpl::Reorder(Id window_id, |
| 144 Id relative_window_id, | 144 Id relative_window_id, |
| 145 mojo::OrderDirection direction) { | 145 mojom::OrderDirection direction) { |
| 146 DCHECK(tree_); | 146 DCHECK(tree_); |
| 147 tree_->ReorderView(window_id, relative_window_id, direction, | 147 tree_->ReorderWindow(window_id, relative_window_id, direction, |
| 148 ActionCompletedCallback()); | 148 ActionCompletedCallback()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool WindowTreeClientImpl::OwnsWindow(Id id) const { | 151 bool WindowTreeClientImpl::OwnsWindow(Id id) const { |
| 152 return HiWord(id) == connection_id_; | 152 return HiWord(id) == connection_id_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void WindowTreeClientImpl::SetBounds(Id window_id, const mojo::Rect& bounds) { | 155 void WindowTreeClientImpl::SetBounds(Id window_id, const mojo::Rect& bounds) { |
| 156 DCHECK(tree_); | 156 DCHECK(tree_); |
| 157 tree_->SetViewBounds(window_id, bounds.Clone(), ActionCompletedCallback()); | 157 tree_->SetWindowBounds(window_id, bounds.Clone(), ActionCompletedCallback()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void WindowTreeClientImpl::SetClientArea(Id window_id, | 160 void WindowTreeClientImpl::SetClientArea(Id window_id, |
| 161 const mojo::Rect& client_area) { | 161 const mojo::Rect& client_area) { |
| 162 DCHECK(tree_); | 162 DCHECK(tree_); |
| 163 tree_->SetClientArea(window_id, client_area.Clone()); | 163 tree_->SetClientArea(window_id, client_area.Clone()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void WindowTreeClientImpl::SetFocus(Id window_id) { | 166 void WindowTreeClientImpl::SetFocus(Id window_id) { |
| 167 // In order for us to get here we had to have exposed a window, which implies | 167 // In order for us to get here we had to have exposed a window, which implies |
| 168 // we | 168 // we |
| 169 // got a connection. | 169 // got a connection. |
| 170 DCHECK(tree_); | 170 DCHECK(tree_); |
| 171 tree_->SetFocus(window_id); | 171 tree_->SetFocus(window_id); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) { | 174 void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) { |
| 175 DCHECK(tree_); | 175 DCHECK(tree_); |
| 176 tree_->SetViewVisibility(window_id, visible, ActionCompletedCallback()); | 176 tree_->SetWindowVisibility(window_id, visible, ActionCompletedCallback()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void WindowTreeClientImpl::SetProperty(Id window_id, | 179 void WindowTreeClientImpl::SetProperty(Id window_id, |
| 180 const std::string& name, | 180 const std::string& name, |
| 181 const std::vector<uint8_t>& data) { | 181 const std::vector<uint8_t>& data) { |
| 182 DCHECK(tree_); | 182 DCHECK(tree_); |
| 183 tree_->SetViewProperty(window_id, mojo::String(name), | 183 tree_->SetWindowProperty(window_id, mojo::String(name), |
| 184 mojo::Array<uint8_t>::From(data), | 184 mojo::Array<uint8_t>::From(data), |
| 185 ActionCompletedCallback()); | 185 ActionCompletedCallback()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void WindowTreeClientImpl::SetViewTextInputState( | 188 void WindowTreeClientImpl::SetWindowTextInputState( |
| 189 Id window_id, | 189 Id window_id, |
| 190 mojo::TextInputStatePtr state) { | 190 mojo::TextInputStatePtr state) { |
| 191 DCHECK(tree_); | 191 DCHECK(tree_); |
| 192 tree_->SetViewTextInputState(window_id, state.Pass()); | 192 tree_->SetWindowTextInputState(window_id, state.Pass()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void WindowTreeClientImpl::SetImeVisibility(Id window_id, | 195 void WindowTreeClientImpl::SetImeVisibility(Id window_id, |
| 196 bool visible, | 196 bool visible, |
| 197 mojo::TextInputStatePtr state) { | 197 mojo::TextInputStatePtr state) { |
| 198 DCHECK(tree_); | 198 DCHECK(tree_); |
| 199 tree_->SetImeVisibility(window_id, visible, state.Pass()); | 199 tree_->SetImeVisibility(window_id, visible, state.Pass()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void WindowTreeClientImpl::Embed( | 202 void WindowTreeClientImpl::Embed( |
| 203 Id window_id, | 203 Id window_id, |
| 204 mojo::ViewTreeClientPtr client, | 204 mus::mojom::WindowTreeClientPtr client, |
| 205 uint32_t policy_bitmask, | 205 uint32_t policy_bitmask, |
| 206 const mojo::ViewTree::EmbedCallback& callback) { | 206 const mus::mojom::WindowTree::EmbedCallback& callback) { |
| 207 DCHECK(tree_); | 207 DCHECK(tree_); |
| 208 tree_->Embed(window_id, client.Pass(), policy_bitmask, callback); | 208 tree_->Embed(window_id, client.Pass(), policy_bitmask, callback); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void WindowTreeClientImpl::RequestSurface( | 211 void WindowTreeClientImpl::RequestSurface( |
| 212 Id window_id, | 212 Id window_id, |
| 213 mojo::InterfaceRequest<mojo::Surface> surface, | 213 mojo::InterfaceRequest<mojom::Surface> surface, |
| 214 mojo::SurfaceClientPtr client) { | 214 mojom::SurfaceClientPtr client) { |
| 215 DCHECK(tree_); | 215 DCHECK(tree_); |
| 216 tree_->RequestSurface(window_id, surface.Pass(), client.Pass()); | 216 tree_->RequestSurface(window_id, surface.Pass(), client.Pass()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void WindowTreeClientImpl::AddWindow(Window* window) { | 219 void WindowTreeClientImpl::AddWindow(Window* window) { |
| 220 DCHECK(windows_.find(window->id()) == windows_.end()); | 220 DCHECK(windows_.find(window->id()) == windows_.end()); |
| 221 windows_[window->id()] = window; | 221 windows_[window->id()] = window; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void WindowTreeClientImpl::RemoveWindow(Id window_id) { | 224 void WindowTreeClientImpl::RemoveWindow(Id window_id) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 238 if (!in_destructor_) | 238 if (!in_destructor_) |
| 239 delete this; | 239 delete this; |
| 240 } | 240 } |
| 241 | 241 |
| 242 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
| 243 // WindowTreeClientImpl, WindowTreeConnection implementation: | 243 // WindowTreeClientImpl, WindowTreeConnection implementation: |
| 244 | 244 |
| 245 Id WindowTreeClientImpl::CreateWindowOnServer() { | 245 Id WindowTreeClientImpl::CreateWindowOnServer() { |
| 246 DCHECK(tree_); | 246 DCHECK(tree_); |
| 247 const Id window_id = MakeTransportId(connection_id_, next_id_++); | 247 const Id window_id = MakeTransportId(connection_id_, next_id_++); |
| 248 tree_->CreateView(window_id, [this](mojo::ErrorCode code) { | 248 tree_->NewWindow(window_id, [this](mojom::ErrorCode code) { |
| 249 OnActionCompleted(code == mojo::ERROR_CODE_NONE); | 249 OnActionCompleted(code == mojom::ERROR_CODE_NONE); |
| 250 }); | 250 }); |
| 251 return window_id; | 251 return window_id; |
| 252 } | 252 } |
| 253 | 253 |
| 254 Window* WindowTreeClientImpl::GetRoot() { | 254 Window* WindowTreeClientImpl::GetRoot() { |
| 255 return root_; | 255 return root_; |
| 256 } | 256 } |
| 257 | 257 |
| 258 Window* WindowTreeClientImpl::GetWindowById(Id id) { | 258 Window* WindowTreeClientImpl::GetWindowById(Id id) { |
| 259 IdToWindowMap::const_iterator it = windows_.find(id); | 259 IdToWindowMap::const_iterator it = windows_.find(id); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 272 | 272 |
| 273 bool WindowTreeClientImpl::IsEmbedRoot() { | 273 bool WindowTreeClientImpl::IsEmbedRoot() { |
| 274 return is_embed_root_; | 274 return is_embed_root_; |
| 275 } | 275 } |
| 276 | 276 |
| 277 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() { | 277 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() { |
| 278 return connection_id_; | 278 return connection_id_; |
| 279 } | 279 } |
| 280 | 280 |
| 281 //////////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////////// |
| 282 // WindowTreeClientImpl, ViewTreeClient implementation: | 282 // WindowTreeClientImpl, WindowTreeClient implementation: |
| 283 | 283 |
| 284 void WindowTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, | 284 void WindowTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, |
| 285 mojo::ViewDataPtr root_data, | 285 mojom::WindowDataPtr root_data, |
| 286 mojo::ViewTreePtr tree, | 286 mus::mojom::WindowTreePtr tree, |
| 287 Id focused_window_id, | 287 Id focused_window_id, |
| 288 uint32 access_policy) { | 288 uint32 access_policy) { |
| 289 if (tree) { | 289 if (tree) { |
| 290 DCHECK(!tree_); | 290 DCHECK(!tree_); |
| 291 tree_ = tree.Pass(); | 291 tree_ = tree.Pass(); |
| 292 tree_.set_connection_error_handler([this]() { delete this; }); | 292 tree_.set_connection_error_handler([this]() { delete this; }); |
| 293 } | 293 } |
| 294 connection_id_ = connection_id; | 294 connection_id_ = connection_id; |
| 295 is_embed_root_ = | 295 is_embed_root_ = |
| 296 (access_policy & mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0; | 296 (access_policy & mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; |
| 297 | 297 |
| 298 DCHECK(!root_); | 298 DCHECK(!root_); |
| 299 root_ = AddWindowToConnection(this, nullptr, root_data); | 299 root_ = AddWindowToConnection(this, nullptr, root_data); |
| 300 | 300 |
| 301 focused_window_ = GetWindowById(focused_window_id); | 301 focused_window_ = GetWindowById(focused_window_id); |
| 302 | 302 |
| 303 delegate_->OnEmbed(root_); | 303 delegate_->OnEmbed(root_); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void WindowTreeClientImpl::OnEmbeddedAppDisconnected(Id window_id) { | 306 void WindowTreeClientImpl::OnEmbeddedAppDisconnected(Id window_id) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 328 mojo::RectPtr old_client_area, | 328 mojo::RectPtr old_client_area, |
| 329 mojo::RectPtr new_client_area) { | 329 mojo::RectPtr new_client_area) { |
| 330 Window* window = GetWindowById(window_id); | 330 Window* window = GetWindowById(window_id); |
| 331 if (window) | 331 if (window) |
| 332 WindowPrivate(window).LocalSetClientArea(*new_client_area); | 332 WindowPrivate(window).LocalSetClientArea(*new_client_area); |
| 333 } | 333 } |
| 334 | 334 |
| 335 namespace { | 335 namespace { |
| 336 | 336 |
| 337 void SetViewportMetricsOnDecendants(Window* root, | 337 void SetViewportMetricsOnDecendants(Window* root, |
| 338 const mojo::ViewportMetrics& old_metrics, | 338 const mojom::ViewportMetrics& old_metrics, |
| 339 const mojo::ViewportMetrics& new_metrics) { | 339 const mojom::ViewportMetrics& new_metrics) { |
| 340 WindowPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); | 340 WindowPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); |
| 341 const Window::Children& children = root->children(); | 341 const Window::Children& children = root->children(); |
| 342 for (size_t i = 0; i < children.size(); ++i) | 342 for (size_t i = 0; i < children.size(); ++i) |
| 343 SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics); | 343 SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 void WindowTreeClientImpl::OnWindowViewportMetricsChanged( | 347 void WindowTreeClientImpl::OnWindowViewportMetricsChanged( |
| 348 mojo::ViewportMetricsPtr old_metrics, | 348 mojom::ViewportMetricsPtr old_metrics, |
| 349 mojo::ViewportMetricsPtr new_metrics) { | 349 mojom::ViewportMetricsPtr new_metrics) { |
| 350 Window* window = GetRoot(); | 350 Window* window = GetRoot(); |
| 351 if (window) | 351 if (window) |
| 352 SetViewportMetricsOnDecendants(window, *old_metrics, *new_metrics); | 352 SetViewportMetricsOnDecendants(window, *old_metrics, *new_metrics); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void WindowTreeClientImpl::OnWindowHierarchyChanged( | 355 void WindowTreeClientImpl::OnWindowHierarchyChanged( |
| 356 Id window_id, | 356 Id window_id, |
| 357 Id new_parent_id, | 357 Id new_parent_id, |
| 358 Id old_parent_id, | 358 Id old_parent_id, |
| 359 mojo::Array<mojo::ViewDataPtr> windows) { | 359 mojo::Array<mojom::WindowDataPtr> windows) { |
| 360 Window* initial_parent = | 360 Window* initial_parent = |
| 361 windows.size() ? GetWindowById(windows[0]->parent_id) : NULL; | 361 windows.size() ? GetWindowById(windows[0]->parent_id) : NULL; |
| 362 | 362 |
| 363 const bool was_window_known = GetWindowById(window_id) != nullptr; | 363 const bool was_window_known = GetWindowById(window_id) != nullptr; |
| 364 | 364 |
| 365 BuildWindowTree(this, windows, initial_parent); | 365 BuildWindowTree(this, windows, initial_parent); |
| 366 | 366 |
| 367 // If the window was not known, then BuildWindowTree() will have created it | 367 // If the window was not known, then BuildWindowTree() will have created it |
| 368 // and | 368 // and |
| 369 // parented the window. | 369 // parented the window. |
| 370 if (!was_window_known) | 370 if (!was_window_known) |
| 371 return; | 371 return; |
| 372 | 372 |
| 373 Window* new_parent = GetWindowById(new_parent_id); | 373 Window* new_parent = GetWindowById(new_parent_id); |
| 374 Window* old_parent = GetWindowById(old_parent_id); | 374 Window* old_parent = GetWindowById(old_parent_id); |
| 375 Window* window = GetWindowById(window_id); | 375 Window* window = GetWindowById(window_id); |
| 376 if (new_parent) | 376 if (new_parent) |
| 377 WindowPrivate(new_parent).LocalAddChild(window); | 377 WindowPrivate(new_parent).LocalAddChild(window); |
| 378 else | 378 else |
| 379 WindowPrivate(old_parent).LocalRemoveChild(window); | 379 WindowPrivate(old_parent).LocalRemoveChild(window); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void WindowTreeClientImpl::OnWindowReordered(Id window_id, | 382 void WindowTreeClientImpl::OnWindowReordered(Id window_id, |
| 383 Id relative_window_id, | 383 Id relative_window_id, |
| 384 mojo::OrderDirection direction) { | 384 mojom::OrderDirection direction) { |
| 385 Window* window = GetWindowById(window_id); | 385 Window* window = GetWindowById(window_id); |
| 386 Window* relative_window = GetWindowById(relative_window_id); | 386 Window* relative_window = GetWindowById(relative_window_id); |
| 387 if (window && relative_window) | 387 if (window && relative_window) |
| 388 WindowPrivate(window).LocalReorder(relative_window, direction); | 388 WindowPrivate(window).LocalReorder(relative_window, direction); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void WindowTreeClientImpl::OnWindowDeleted(Id window_id) { | 391 void WindowTreeClientImpl::OnWindowDeleted(Id window_id) { |
| 392 Window* window = GetWindowById(window_id); | 392 Window* window = GetWindowById(window_id); |
| 393 if (window) | 393 if (window) |
| 394 WindowPrivate(window).LocalDestroy(); | 394 WindowPrivate(window).LocalDestroy(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 void WindowTreeClientImpl::OnActionCompleted(bool success) { | 462 void WindowTreeClientImpl::OnActionCompleted(bool success) { |
| 463 if (!change_acked_callback_.is_null()) | 463 if (!change_acked_callback_.is_null()) |
| 464 change_acked_callback_.Run(); | 464 change_acked_callback_.Run(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { | 467 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { |
| 468 return [this](bool success) { OnActionCompleted(success); }; | 468 return [this](bool success) { OnActionCompleted(success); }; |
| 469 } | 469 } |
| 470 | 470 |
| 471 } // namespace mus | 471 } // namespace mus |
| OLD | NEW |