| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // This function is only called for windows coming from other clients. | 472 // This function is only called for windows coming from other clients. |
| 473 std::unique_ptr<WindowPortMus> window_port_mus( | 473 std::unique_ptr<WindowPortMus> window_port_mus( |
| 474 CreateWindowPortMus(window_data, WindowMusType::OTHER)); | 474 CreateWindowPortMus(window_data, WindowMusType::OTHER)); |
| 475 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); | 475 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); |
| 476 Window* window = new Window(nullptr, std::move(window_port_mus)); | 476 Window* window = new Window(nullptr, std::move(window_port_mus)); |
| 477 WindowMus* window_mus = window_port_mus_ptr; | 477 WindowMus* window_mus = window_port_mus_ptr; |
| 478 SetWindowTypeFromProperties(window, window_data.properties); | 478 SetWindowTypeFromProperties(window, window_data.properties); |
| 479 window->Init(ui::LAYER_NOT_DRAWN); | 479 window->Init(ui::LAYER_NOT_DRAWN); |
| 480 SetLocalPropertiesFromServerProperties(window_mus, window_data); | 480 SetLocalPropertiesFromServerProperties(window_mus, window_data); |
| 481 window_mus->SetBoundsFromServer( | 481 window_mus->SetBoundsFromServer( |
| 482 gfx::ConvertRectToDIP(ScaleFactorForDisplay(window), window_data.bounds)); | 482 gfx::ConvertRectToDIP(ScaleFactorForDisplay(window), window_data.bounds), |
| 483 base::nullopt); |
| 483 if (parent) | 484 if (parent) |
| 484 parent->AddChildFromServer(window_port_mus_ptr); | 485 parent->AddChildFromServer(window_port_mus_ptr); |
| 485 if (window_data.visible) | 486 if (window_data.visible) |
| 486 window_mus->SetVisibleFromServer(true); | 487 window_mus->SetVisibleFromServer(true); |
| 487 return window_port_mus_ptr; | 488 return window_port_mus_ptr; |
| 488 } | 489 } |
| 489 | 490 |
| 490 void WindowTreeClient::SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr) { | 491 void WindowTreeClient::SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr) { |
| 491 tree_ptr_ = std::move(window_tree_ptr); | 492 tree_ptr_ = std::move(window_tree_ptr); |
| 492 | 493 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // WindowTreeHost expects bounds to be in pixels. | 600 // WindowTreeHost expects bounds to be in pixels. |
| 600 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); | 601 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); |
| 601 if (enable_surface_synchronization_ && local_surface_id && | 602 if (enable_surface_synchronization_ && local_surface_id && |
| 602 local_surface_id->is_valid()) { | 603 local_surface_id->is_valid()) { |
| 603 window->GetWindow()->GetHost()->compositor()->SetLocalSurfaceId( | 604 window->GetWindow()->GetHost()->compositor()->SetLocalSurfaceId( |
| 604 *local_surface_id); | 605 *local_surface_id); |
| 605 } | 606 } |
| 606 return; | 607 return; |
| 607 } | 608 } |
| 608 | 609 |
| 609 window->SetBoundsFromServer(gfx::ConvertRectToDIP( | 610 window->SetBoundsFromServer( |
| 610 ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels)); | 611 gfx::ConvertRectToDIP(ScaleFactorForDisplay(window->GetWindow()), |
| 612 revert_bounds_in_pixels), |
| 613 local_surface_id); |
| 611 } | 614 } |
| 612 | 615 |
| 613 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, | 616 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, |
| 614 bool visible) { | 617 bool visible) { |
| 615 if (!IsRoot(window)) { | 618 if (!IsRoot(window)) { |
| 616 window->SetVisibleFromServer(visible); | 619 window->SetVisibleFromServer(visible); |
| 617 return; | 620 return; |
| 618 } | 621 } |
| 619 | 622 |
| 620 std::unique_ptr<WindowMusChangeData> data = | 623 std::unique_ptr<WindowMusChangeData> data = |
| 621 window->PrepareForServerVisibilityChange(visible); | 624 window->PrepareForServerVisibilityChange(visible); |
| 622 WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window); | 625 WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window); |
| 623 if (visible) | 626 if (visible) |
| 624 window_tree_host->Show(); | 627 window_tree_host->Show(); |
| 625 else | 628 else |
| 626 window_tree_host->Hide(); | 629 window_tree_host->Hide(); |
| 627 } | 630 } |
| 628 | 631 |
| 629 void WindowTreeClient::ScheduleInFlightBoundsChange( | 632 void WindowTreeClient::ScheduleInFlightBoundsChange( |
| 630 WindowMus* window, | 633 WindowMus* window, |
| 631 const gfx::Rect& old_bounds, | 634 const gfx::Rect& old_bounds, |
| 632 const gfx::Rect& new_bounds) { | 635 const gfx::Rect& new_bounds) { |
| 633 // TODO(fsamuel): Allocate a new LocalSurfaceId on size change. | |
| 634 const uint32_t change_id = | 636 const uint32_t change_id = |
| 635 ScheduleInFlightChange(base::MakeUnique<InFlightBoundsChange>( | 637 ScheduleInFlightChange(base::MakeUnique<InFlightBoundsChange>( |
| 636 this, window, old_bounds, base::nullopt)); | 638 this, window, old_bounds, window->GetLocalSurfaceId())); |
| 639 base::Optional<cc::LocalSurfaceId> local_surface_id; |
| 640 if ((window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| 641 window->window_mus_type() == WindowMusType::EMBED_IN_OWNER)) { |
| 642 local_surface_id = window->GetOrAllocateLocalSurfaceId(new_bounds.size()); |
| 643 } |
| 637 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds, | 644 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds, |
| 638 base::nullopt); | 645 local_surface_id); |
| 639 } | 646 } |
| 640 | 647 |
| 641 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { | 648 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { |
| 642 if (window->server_id() != kInvalidServerId) | 649 if (window->server_id() != kInvalidServerId) |
| 643 return; | 650 return; |
| 644 | 651 |
| 645 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); | 652 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); |
| 646 RegisterWindowMus(window); | 653 RegisterWindowMus(window); |
| 647 | 654 |
| 648 DCHECK(window_manager_delegate_ || !IsRoot(window)); | 655 DCHECK(window_manager_delegate_ || !IsRoot(window)); |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1948 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1942 this, capture_synchronizer_.get(), window)); | 1949 this, capture_synchronizer_.get(), window)); |
| 1943 } | 1950 } |
| 1944 | 1951 |
| 1945 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1952 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1946 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1953 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1947 this, focus_synchronizer_.get(), window)); | 1954 this, focus_synchronizer_.get(), window)); |
| 1948 } | 1955 } |
| 1949 | 1956 |
| 1950 } // namespace aura | 1957 } // namespace aura |
| OLD | NEW |