| 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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 client_id_ = 101; | 219 client_id_ = 101; |
| 220 | 220 |
| 221 ui::mojom::WindowTreeFactoryPtr factory; | 221 ui::mojom::WindowTreeFactoryPtr factory; |
| 222 connector_->BindInterface(ui::mojom::kServiceName, &factory); | 222 connector_->BindInterface(ui::mojom::kServiceName, &factory); |
| 223 ui::mojom::WindowTreePtr window_tree; | 223 ui::mojom::WindowTreePtr window_tree; |
| 224 factory->CreateWindowTree(MakeRequest(&window_tree), | 224 factory->CreateWindowTree(MakeRequest(&window_tree), |
| 225 binding_.CreateInterfacePtrAndBind()); | 225 binding_.CreateInterfacePtrAndBind()); |
| 226 SetWindowTree(std::move(window_tree)); | 226 SetWindowTree(std::move(window_tree)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void WindowTreeClient::ConnectViaWindowTreeHostFactory() { |
| 230 // The client id doesn't really matter, we use 101 purely for debugging. |
| 231 client_id_ = 101; |
| 232 |
| 233 ui::mojom::WindowTreeHostFactoryRegistrarPtr host_factory_registrar; |
| 234 connector_->BindInterface(ui::mojom::kServiceName, &host_factory_registrar); |
| 235 |
| 236 ui::mojom::WindowTreePtr window_tree; |
| 237 host_factory_registrar->Register(MakeRequest(&window_tree_host_factory_ptr_), |
| 238 MakeRequest(&window_tree), |
| 239 binding_.CreateInterfacePtrAndBind()); |
| 240 SetWindowTree(std::move(window_tree)); |
| 241 } |
| 242 |
| 229 void WindowTreeClient::ConnectAsWindowManager() { | 243 void WindowTreeClient::ConnectAsWindowManager() { |
| 230 DCHECK(window_manager_delegate_); | 244 DCHECK(window_manager_delegate_); |
| 231 | 245 |
| 232 ui::mojom::WindowManagerWindowTreeFactoryPtr factory; | 246 ui::mojom::WindowManagerWindowTreeFactoryPtr factory; |
| 233 connector_->BindInterface(ui::mojom::kServiceName, &factory); | 247 connector_->BindInterface(ui::mojom::kServiceName, &factory); |
| 234 ui::mojom::WindowTreePtr window_tree; | 248 ui::mojom::WindowTreePtr window_tree; |
| 235 factory->CreateWindowTree(MakeRequest(&window_tree), | 249 factory->CreateWindowTree(MakeRequest(&window_tree), |
| 236 binding_.CreateInterfacePtrAndBind()); | 250 binding_.CreateInterfacePtrAndBind()); |
| 237 SetWindowTree(std::move(window_tree)); | 251 SetWindowTree(std::move(window_tree)); |
| 238 } | 252 } |
| 239 | 253 |
| 254 void WindowTreeClient::CreateHost(ui::mojom::WindowTreeHostRequest host) { |
| 255 window_tree_host_factory_ptr_->CreateWindowTreeHost(std::move(host)); |
| 256 } |
| 257 |
| 240 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { | 258 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { |
| 241 DCHECK(tree_); | 259 DCHECK(tree_); |
| 242 DCHECK(window); | 260 DCHECK(window); |
| 243 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); | 261 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); |
| 244 } | 262 } |
| 245 | 263 |
| 246 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, | 264 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, |
| 247 ui::mojom::Cursor old_cursor, | 265 ui::mojom::Cursor old_cursor, |
| 248 ui::mojom::Cursor new_cursor) { | 266 ui::mojom::Cursor new_cursor) { |
| 249 DCHECK(tree_); | 267 DCHECK(tree_); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 ClientSpecificId client_id, | 516 ClientSpecificId client_id, |
| 499 ui::mojom::WindowDataPtr root_data, | 517 ui::mojom::WindowDataPtr root_data, |
| 500 int64_t display_id, | 518 int64_t display_id, |
| 501 Id focused_window_id, | 519 Id focused_window_id, |
| 502 bool drawn) { | 520 bool drawn) { |
| 503 // WARNING: this is only called if WindowTreeClient was created as the | 521 // WARNING: this is only called if WindowTreeClient was created as the |
| 504 // result of an embedding. | 522 // result of an embedding. |
| 505 client_id_ = client_id; | 523 client_id_ = client_id; |
| 506 WindowTreeConnectionEstablished(window_tree); | 524 WindowTreeConnectionEstablished(window_tree); |
| 507 | 525 |
| 508 DCHECK(roots_.empty()); | |
| 509 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 526 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
| 510 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id); | 527 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id); |
| 511 | 528 |
| 512 focus_synchronizer_->SetFocusFromServer( | 529 focus_synchronizer_->SetFocusFromServer( |
| 513 GetWindowByServerId(focused_window_id)); | 530 GetWindowByServerId(focused_window_id)); |
| 514 | 531 |
| 515 delegate_->OnEmbed(std::move(window_tree_host)); | 532 delegate_->OnEmbed(std::move(window_tree_host)); |
| 516 } | 533 } |
| 517 | 534 |
| 518 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( | 535 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 DCHECK(tree_); | 849 DCHECK(tree_); |
| 833 tree_->SetEventTargetingPolicy(window->server_id(), policy); | 850 tree_->SetEventTargetingPolicy(window->server_id(), policy); |
| 834 } | 851 } |
| 835 | 852 |
| 836 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, | 853 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, |
| 837 ui::mojom::WindowDataPtr root_data, | 854 ui::mojom::WindowDataPtr root_data, |
| 838 ui::mojom::WindowTreePtr tree, | 855 ui::mojom::WindowTreePtr tree, |
| 839 int64_t display_id, | 856 int64_t display_id, |
| 840 Id focused_window_id, | 857 Id focused_window_id, |
| 841 bool drawn) { | 858 bool drawn) { |
| 842 DCHECK(!tree_ptr_); | 859 // No need to set 'tree_ptr_' whether it was already set during |
| 843 tree_ptr_ = std::move(tree); | 860 // ConnectViaWindowManagerHostFactory. |
| 861 DCHECK((tree_ptr_ && !tree) || (!tree_ptr_ && tree)); |
| 862 if (tree) { |
| 863 DCHECK(roots_.empty()); |
| 864 tree_ptr_ = std::move(tree); |
| 865 } |
| 844 | 866 |
| 845 is_from_embed_ = true; | 867 is_from_embed_ = true; |
| 846 | 868 |
| 847 if (window_manager_delegate_) { | 869 if (window_manager_delegate_) { |
| 848 tree_ptr_->GetWindowManagerClient( | 870 tree_ptr_->GetWindowManagerClient( |
| 849 MakeRequest(&window_manager_internal_client_)); | 871 MakeRequest(&window_manager_internal_client_)); |
| 850 } | 872 } |
| 851 | 873 |
| 852 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, | 874 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, |
| 853 focused_window_id, drawn); | 875 focused_window_id, drawn); |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1850 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1829 this, capture_synchronizer_.get(), window)); | 1851 this, capture_synchronizer_.get(), window)); |
| 1830 } | 1852 } |
| 1831 | 1853 |
| 1832 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1854 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1833 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1855 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1834 this, focus_synchronizer_.get(), window)); | 1856 this, focus_synchronizer_.get(), window)); |
| 1835 } | 1857 } |
| 1836 | 1858 |
| 1837 } // namespace aura | 1859 } // namespace aura |
| OLD | NEW |