Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_port_mus.h" | 5 #include "ui/aura/mus/window_port_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/transient_window_client.h" | 9 #include "ui/aura/client/transient_window_client.h" |
| 10 #include "ui/aura/mus/client_surface_embedder.h" | 10 #include "ui/aura/mus/client_surface_embedder.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 // static | 37 // static |
| 38 WindowMus* WindowMus::Get(Window* window) { | 38 WindowMus* WindowMus::Get(Window* window) { |
| 39 return WindowPortMus::Get(window); | 39 return WindowPortMus::Get(window); |
| 40 } | 40 } |
| 41 | 41 |
| 42 WindowPortMus::WindowPortMus(WindowTreeClient* client, | 42 WindowPortMus::WindowPortMus(WindowTreeClient* client, |
| 43 WindowMusType window_mus_type) | 43 WindowMusType window_mus_type) |
| 44 : WindowMus(window_mus_type), window_tree_client_(client) {} | 44 : WindowMus(window_mus_type), window_tree_client_(client) {} |
| 45 | 45 |
| 46 WindowPortMus::~WindowPortMus() { | 46 WindowPortMus::~WindowPortMus() { |
| 47 SetPrimarySurfaceInfo(cc::SurfaceInfo()); | 47 // SetPrimarySurfaceInfo(cc::SurfaceInfo()); |
|
sadrul
2017/04/07 13:07:33
Remove
Fady Samuel
2017/04/07 15:27:25
Done.
| |
| 48 client_surface_embedder_.reset(); | |
| 48 | 49 |
| 49 // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is | 50 // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is |
| 50 // present then the server originated the change. | 51 // present then the server originated the change. |
| 51 const WindowTreeClient::Origin origin = | 52 const WindowTreeClient::Origin origin = |
| 52 RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData()) | 53 RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData()) |
| 53 ? WindowTreeClient::Origin::SERVER | 54 ? WindowTreeClient::Origin::SERVER |
| 54 : WindowTreeClient::Origin::CLIENT; | 55 : WindowTreeClient::Origin::CLIENT; |
| 55 window_tree_client_->OnWindowMusDestroyed(this, origin); | 56 window_tree_client_->OnWindowMusDestroyed(this, origin); |
| 56 } | 57 } |
| 57 | 58 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 return local_surface_id_; | 322 return local_surface_id_; |
| 322 } | 323 } |
| 323 | 324 |
| 324 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { | 325 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { |
| 325 primary_surface_info_ = surface_info; | 326 primary_surface_info_ = surface_info; |
| 326 UpdateClientSurfaceEmbedder(); | 327 UpdateClientSurfaceEmbedder(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void WindowPortMus::SetFallbackSurfaceInfo( | 330 void WindowPortMus::SetFallbackSurfaceInfo( |
| 330 const cc::SurfaceInfo& surface_info) { | 331 const cc::SurfaceInfo& surface_info) { |
| 331 DCHECK(client_surface_embedder_); | 332 fallback_surface_info_ = surface_info; |
| 332 client_surface_embedder_->SetFallbackSurfaceInfo(surface_info); | 333 UpdateClientSurfaceEmbedder(); |
| 333 } | 334 } |
| 334 | 335 |
| 335 void WindowPortMus::DestroyFromServer() { | 336 void WindowPortMus::DestroyFromServer() { |
| 336 std::unique_ptr<ScopedServerChange> remove_from_parent_change; | 337 std::unique_ptr<ScopedServerChange> remove_from_parent_change; |
| 337 if (window_->parent()) { | 338 if (window_->parent()) { |
| 338 ServerChangeData data; | 339 ServerChangeData data; |
| 339 data.child_id = server_id(); | 340 data.child_id = server_id(); |
| 340 WindowPortMus* parent = Get(window_->parent()); | 341 WindowPortMus* parent = Get(window_->parent()); |
| 341 remove_from_parent_change = base::MakeUnique<ScopedServerChange>( | 342 remove_from_parent_change = base::MakeUnique<ScopedServerChange>( |
| 342 parent, ServerChangeType::REMOVE, data); | 343 parent, ServerChangeType::REMOVE, data); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 change_data) == server_changes_.end()) { | 471 change_data) == server_changes_.end()) { |
| 471 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); | 472 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); |
| 472 } | 473 } |
| 473 } | 474 } |
| 474 | 475 |
| 475 void WindowPortMus::OnVisibilityChanged(bool visible) { | 476 void WindowPortMus::OnVisibilityChanged(bool visible) { |
| 476 ServerChangeData change_data; | 477 ServerChangeData change_data; |
| 477 change_data.visible = visible; | 478 change_data.visible = visible; |
| 478 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) | 479 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) |
| 479 window_tree_client_->OnWindowMusSetVisible(this, visible); | 480 window_tree_client_->OnWindowMusSetVisible(this, visible); |
| 480 // We should only embed a client if its visible. | |
| 481 UpdateClientSurfaceEmbedder(); | |
| 482 } | 481 } |
| 483 | 482 |
| 484 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, | 483 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, |
| 485 const gfx::Rect& new_bounds) { | 484 const gfx::Rect& new_bounds) { |
| 486 ServerChangeData change_data; | 485 ServerChangeData change_data; |
| 487 change_data.bounds_in_dip = new_bounds; | 486 change_data.bounds_in_dip = new_bounds; |
| 488 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data)) | 487 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data)) |
| 489 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds); | 488 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds); |
| 489 if (client_surface_embedder_) | |
| 490 client_surface_embedder_->UpdateSizeAndGutters(); | |
| 490 } | 491 } |
| 491 | 492 |
| 492 std::unique_ptr<ui::PropertyData> WindowPortMus::OnWillChangeProperty( | 493 std::unique_ptr<ui::PropertyData> WindowPortMus::OnWillChangeProperty( |
| 493 const void* key) { | 494 const void* key) { |
| 494 // |window_| is null if a property is set on the aura::Window before | 495 // |window_| is null if a property is set on the aura::Window before |
| 495 // Window::Init() is called. It's safe to ignore the change in this case as | 496 // Window::Init() is called. It's safe to ignore the change in this case as |
| 496 // once Window::Init() is called the Window is queried for the current set of | 497 // once Window::Init() is called the Window is queried for the current set of |
| 497 // properties. | 498 // properties. |
| 498 if (!window_) | 499 if (!window_) |
| 499 return nullptr; | 500 return nullptr; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 529 return; | 530 return; |
| 530 | 531 |
| 531 primary_surface_info_ = | 532 primary_surface_info_ = |
| 532 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_), | 533 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| 533 ScaleFactorForDisplay(window_), last_surface_size_); | 534 ScaleFactorForDisplay(window_), last_surface_size_); |
| 534 | 535 |
| 535 UpdateClientSurfaceEmbedder(); | 536 UpdateClientSurfaceEmbedder(); |
| 536 } | 537 } |
| 537 | 538 |
| 538 void WindowPortMus::UpdateClientSurfaceEmbedder() { | 539 void WindowPortMus::UpdateClientSurfaceEmbedder() { |
| 539 if (!client_surface_embedder_ && primary_surface_info_.is_valid()) | 540 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| 540 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(window_); | 541 window_mus_type() == WindowMusType::EMBED_IN_OWNER; |
| 542 if (!embeds_surface) | |
| 543 return; | |
| 541 | 544 |
| 542 if (primary_surface_info_.is_valid() && window_->IsVisible()) | 545 if (!client_surface_embedder_) { |
| 543 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); | 546 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( |
| 544 else | 547 window_, window_tree_client_->normal_client_area_insets_); |
| 545 client_surface_embedder_.reset(); | 548 } |
| 549 | |
| 550 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); | |
| 551 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); | |
| 546 } | 552 } |
| 547 | 553 |
| 548 } // namespace aura | 554 } // namespace aura |
| OLD | NEW |