| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds); | 528 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { | 531 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { |
| 532 if (window->server_id() != kInvalidServerId) | 532 if (window->server_id() != kInvalidServerId) |
| 533 return; | 533 return; |
| 534 | 534 |
| 535 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); | 535 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); |
| 536 RegisterWindowMus(window); | 536 RegisterWindowMus(window); |
| 537 | 537 |
| 538 const bool create_top_level = !window_manager_delegate_ && IsRoot(window); | 538 DCHECK(window_manager_delegate_ || !IsRoot(window)); |
| 539 | 539 |
| 540 std::unordered_map<std::string, std::vector<uint8_t>> transport_properties; | 540 std::unordered_map<std::string, std::vector<uint8_t>> transport_properties; |
| 541 std::set<const void*> property_keys = | 541 std::set<const void*> property_keys = |
| 542 window->GetWindow()->GetAllPropertKeys(); | 542 window->GetWindow()->GetAllPropertKeys(); |
| 543 PropertyConverter* property_converter = delegate_->GetPropertyConverter(); | 543 PropertyConverter* property_converter = delegate_->GetPropertyConverter(); |
| 544 for (const void* key : property_keys) { | 544 for (const void* key : property_keys) { |
| 545 std::string transport_name; | 545 std::string transport_name; |
| 546 std::unique_ptr<std::vector<uint8_t>> transport_value; | 546 std::unique_ptr<std::vector<uint8_t>> transport_value; |
| 547 if (!property_converter->ConvertPropertyForTransport( | 547 if (!property_converter->ConvertPropertyForTransport( |
| 548 window->GetWindow(), key, &transport_name, &transport_value)) { | 548 window->GetWindow(), key, &transport_name, &transport_value)) { |
| 549 continue; | 549 continue; |
| 550 } | 550 } |
| 551 if (!transport_value) { | 551 if (!transport_value) { |
| 552 transport_properties[transport_name] = std::vector<uint8_t>(); | 552 transport_properties[transport_name] = std::vector<uint8_t>(); |
| 553 } else { | 553 } else { |
| 554 transport_properties[transport_name] = std::move(*transport_value); | 554 transport_properties[transport_name] = std::move(*transport_value); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 const uint32_t change_id = | 558 const uint32_t change_id = ScheduleInFlightChange( |
| 559 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( | 559 base::MakeUnique<CrashInFlightChange>(window, ChangeType::NEW_WINDOW)); |
| 560 window, create_top_level ? ChangeType::NEW_TOP_LEVEL_WINDOW | 560 tree_->NewWindow(change_id, window->server_id(), |
| 561 : ChangeType::NEW_WINDOW)); | 561 std::move(transport_properties)); |
| 562 if (create_top_level) { | |
| 563 tree_->NewTopLevelWindow(change_id, window->server_id(), | |
| 564 transport_properties); | |
| 565 } else { | |
| 566 tree_->NewWindow(change_id, window->server_id(), | |
| 567 std::move(transport_properties)); | |
| 568 } | |
| 569 } | 562 } |
| 570 | 563 |
| 571 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { | 564 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { |
| 572 if (focus_synchronizer_->focused_window() == window) | 565 if (focus_synchronizer_->focused_window() == window) |
| 573 focus_synchronizer_->OnFocusedWindowDestroyed(); | 566 focus_synchronizer_->OnFocusedWindowDestroyed(); |
| 574 | 567 |
| 575 // TODO: decide how to deal with windows not owned by this client. | 568 // TODO: decide how to deal with windows not owned by this client. |
| 576 if (origin == Origin::CLIENT && | 569 if (origin == Origin::CLIENT && |
| 577 (WasCreatedByThisClient(window) || IsRoot(window))) { | 570 (WasCreatedByThisClient(window) || IsRoot(window))) { |
| 578 const uint32_t change_id = | 571 const uint32_t change_id = |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 base::Optional<gfx::Rect> out_rect = base::nullopt; | 1519 base::Optional<gfx::Rect> out_rect = base::nullopt; |
| 1527 if (mask_rect) { | 1520 if (mask_rect) { |
| 1528 out_rect = gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), | 1521 out_rect = gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), |
| 1529 mask_rect.value()); | 1522 mask_rect.value()); |
| 1530 } | 1523 } |
| 1531 | 1524 |
| 1532 tree_->SetHitTestMask(WindowMus::Get(window_tree_host->window())->server_id(), | 1525 tree_->SetHitTestMask(WindowMus::Get(window_tree_host->window())->server_id(), |
| 1533 out_rect); | 1526 out_rect); |
| 1534 } | 1527 } |
| 1535 | 1528 |
| 1536 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() { | 1529 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel( |
| 1530 const std::map<std::string, std::vector<uint8_t>>* properties) { |
| 1537 std::unique_ptr<WindowPortMus> window_port = | 1531 std::unique_ptr<WindowPortMus> window_port = |
| 1538 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); | 1532 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); |
| 1539 roots_.insert(window_port.get()); | 1533 roots_.insert(window_port.get()); |
| 1534 |
| 1535 window_port->set_server_id(MakeTransportId(client_id_, next_window_id_++)); |
| 1536 RegisterWindowMus(window_port.get()); |
| 1537 |
| 1538 std::unordered_map<std::string, std::vector<uint8_t>> transport_properties; |
| 1539 if (properties) { |
| 1540 for (const auto& property_pair : *properties) |
| 1541 transport_properties[property_pair.first] = property_pair.second; |
| 1542 } |
| 1543 |
| 1544 const uint32_t change_id = |
| 1545 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( |
| 1546 window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW)); |
| 1547 tree_->NewTopLevelWindow(change_id, window_port->server_id(), |
| 1548 transport_properties); |
| 1540 return window_port; | 1549 return window_port; |
| 1541 } | 1550 } |
| 1542 | 1551 |
| 1543 void WindowTreeClient::OnWindowTreeHostCreated( | 1552 void WindowTreeClient::OnWindowTreeHostCreated( |
| 1544 WindowTreeHostMus* window_tree_host) { | 1553 WindowTreeHostMus* window_tree_host) { |
| 1545 // All WindowTreeHosts are destroyed before this, so we don't need to unset | 1554 // All WindowTreeHosts are destroyed before this, so we don't need to unset |
| 1546 // the DragDropClient. | 1555 // the DragDropClient. |
| 1547 client::SetDragDropClient(window_tree_host->window(), | 1556 client::SetDragDropClient(window_tree_host->window(), |
| 1548 drag_drop_controller_.get()); | 1557 drag_drop_controller_.get()); |
| 1549 } | 1558 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1615 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1607 this, capture_synchronizer_.get(), window)); | 1616 this, capture_synchronizer_.get(), window)); |
| 1608 } | 1617 } |
| 1609 | 1618 |
| 1610 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1619 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1611 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1620 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1612 this, focus_synchronizer_.get(), window)); | 1621 this, focus_synchronizer_.get(), window)); |
| 1613 } | 1622 } |
| 1614 | 1623 |
| 1615 } // namespace aura | 1624 } // namespace aura |
| OLD | NEW |