| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 const InFlightChange& change) { | 348 const InFlightChange& change) { |
| 349 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change); | 349 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change); |
| 350 if (!existing_change) | 350 if (!existing_change) |
| 351 return false; | 351 return false; |
| 352 | 352 |
| 353 existing_change->SetRevertValueFrom(change); | 353 existing_change->SetRevertValueFrom(change); |
| 354 return true; | 354 return true; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void WindowTreeClient::BuildWindowTree( | 357 void WindowTreeClient::BuildWindowTree( |
| 358 const mojo::Array<ui::mojom::WindowDataPtr>& windows, | 358 const mojo::Array<ui::mojom::WindowDataPtr>& windows) { |
| 359 WindowMus* initial_parent) { | |
| 360 std::vector<WindowMus*> parents; | |
| 361 WindowMus* last_window = nullptr; | |
| 362 if (initial_parent) | |
| 363 parents.push_back(initial_parent); | |
| 364 for (const auto& window_data : windows) { | 359 for (const auto& window_data : windows) { |
| 365 if (last_window && window_data->parent_id == last_window->server_id()) { | 360 WindowMus* parent = window_data->parent_id == kInvalidServerId |
| 366 parents.push_back(last_window); | 361 ? nullptr |
| 367 } else if (!parents.empty()) { | 362 : GetWindowByServerId(window_data->parent_id); |
| 368 while (parents.back()->server_id() != window_data->parent_id) | 363 WindowMus* existing_window = GetWindowByServerId(window_data->window_id); |
| 369 parents.pop_back(); | 364 if (!existing_window) |
| 370 } | 365 NewWindowFromWindowData(parent, window_data); |
| 371 // This code is only called in a context where there is a parent. | 366 else if (parent) |
| 372 DCHECK(!parents.empty()); | 367 parent->AddChildFromServer(existing_window); |
| 373 last_window = NewWindowFromWindowData( | |
| 374 !parents.empty() ? parents.back() : nullptr, window_data); | |
| 375 } | 368 } |
| 376 } | 369 } |
| 377 | 370 |
| 378 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus( | 371 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus( |
| 379 const ui::mojom::WindowDataPtr& window_data, | 372 const ui::mojom::WindowDataPtr& window_data, |
| 380 WindowMusType window_mus_type) { | 373 WindowMusType window_mus_type) { |
| 381 std::unique_ptr<WindowPortMus> window_port_mus( | 374 std::unique_ptr<WindowPortMus> window_port_mus( |
| 382 base::MakeUnique<WindowPortMus>(this, window_mus_type)); | 375 base::MakeUnique<WindowPortMus>(this, window_mus_type)); |
| 383 window_port_mus->set_server_id(window_data->window_id); | 376 window_port_mus->set_server_id(window_data->window_id); |
| 384 RegisterWindowMus(window_port_mus.get()); | 377 RegisterWindowMus(window_port_mus.get()); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 // with an in flight delete from the server. | 1010 // with an in flight delete from the server. |
| 1018 if (window && transient_window) | 1011 if (window && transient_window) |
| 1019 window->RemoveTransientChildFromServer(transient_window); | 1012 window->RemoveTransientChildFromServer(transient_window); |
| 1020 } | 1013 } |
| 1021 | 1014 |
| 1022 void WindowTreeClient::OnWindowHierarchyChanged( | 1015 void WindowTreeClient::OnWindowHierarchyChanged( |
| 1023 Id window_id, | 1016 Id window_id, |
| 1024 Id old_parent_id, | 1017 Id old_parent_id, |
| 1025 Id new_parent_id, | 1018 Id new_parent_id, |
| 1026 mojo::Array<ui::mojom::WindowDataPtr> windows) { | 1019 mojo::Array<ui::mojom::WindowDataPtr> windows) { |
| 1027 WindowMus* initial_parent = | |
| 1028 windows.size() ? GetWindowByServerId(windows[0]->parent_id) : nullptr; | |
| 1029 | |
| 1030 const bool was_window_known = GetWindowByServerId(window_id) != nullptr; | 1020 const bool was_window_known = GetWindowByServerId(window_id) != nullptr; |
| 1031 | 1021 |
| 1032 BuildWindowTree(windows, initial_parent); | 1022 BuildWindowTree(windows); |
| 1033 | 1023 |
| 1034 // If the window was not known, then BuildWindowTree() will have created it | 1024 // If the window was not known, then BuildWindowTree() will have created it |
| 1035 // and parented the window. | 1025 // and parented the window. |
| 1036 if (!was_window_known) | 1026 if (!was_window_known) |
| 1037 return; | 1027 return; |
| 1038 | 1028 |
| 1039 WindowMus* new_parent = GetWindowByServerId(new_parent_id); | 1029 WindowMus* new_parent = GetWindowByServerId(new_parent_id); |
| 1040 WindowMus* old_parent = GetWindowByServerId(old_parent_id); | 1030 WindowMus* old_parent = GetWindowByServerId(old_parent_id); |
| 1041 WindowMus* window = GetWindowByServerId(window_id); | 1031 WindowMus* window = GetWindowByServerId(window_id); |
| 1042 if (new_parent) | 1032 if (new_parent) |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 return ScheduleInFlightChange( | 1582 return ScheduleInFlightChange( |
| 1593 base::MakeUnique<InFlightDragChange>(window, ChangeType::DRAG_LOOP)); | 1583 base::MakeUnique<InFlightDragChange>(window, ChangeType::DRAG_LOOP)); |
| 1594 } | 1584 } |
| 1595 | 1585 |
| 1596 uint32_t WindowTreeClient::CreateChangeIdForCapture(WindowMus* window) { | 1586 uint32_t WindowTreeClient::CreateChangeIdForCapture(WindowMus* window) { |
| 1597 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1587 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1598 this, capture_synchronizer_.get(), window)); | 1588 this, capture_synchronizer_.get(), window)); |
| 1599 } | 1589 } |
| 1600 | 1590 |
| 1601 } // namespace aura | 1591 } // namespace aura |
| OLD | NEW |