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 client_surface_embedder_.reset(); |
48 | 48 |
49 // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is | 49 // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is |
50 // present then the server originated the change. | 50 // present then the server originated the change. |
51 const WindowTreeClient::Origin origin = | 51 const WindowTreeClient::Origin origin = |
52 RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData()) | 52 RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData()) |
53 ? WindowTreeClient::Origin::SERVER | 53 ? WindowTreeClient::Origin::SERVER |
54 : WindowTreeClient::Origin::CLIENT; | 54 : WindowTreeClient::Origin::CLIENT; |
55 window_tree_client_->OnWindowMusDestroyed(this, origin); | 55 window_tree_client_->OnWindowMusDestroyed(this, origin); |
56 } | 56 } |
57 | 57 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 return local_surface_id_; | 321 return local_surface_id_; |
322 } | 322 } |
323 | 323 |
324 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { | 324 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { |
325 primary_surface_info_ = surface_info; | 325 primary_surface_info_ = surface_info; |
326 UpdateClientSurfaceEmbedder(); | 326 UpdateClientSurfaceEmbedder(); |
327 } | 327 } |
328 | 328 |
329 void WindowPortMus::SetFallbackSurfaceInfo( | 329 void WindowPortMus::SetFallbackSurfaceInfo( |
330 const cc::SurfaceInfo& surface_info) { | 330 const cc::SurfaceInfo& surface_info) { |
331 DCHECK(client_surface_embedder_); | 331 fallback_surface_info_ = surface_info; |
332 client_surface_embedder_->SetFallbackSurfaceInfo(surface_info); | 332 UpdateClientSurfaceEmbedder(); |
333 } | 333 } |
334 | 334 |
335 void WindowPortMus::DestroyFromServer() { | 335 void WindowPortMus::DestroyFromServer() { |
336 std::unique_ptr<ScopedServerChange> remove_from_parent_change; | 336 std::unique_ptr<ScopedServerChange> remove_from_parent_change; |
337 if (window_->parent()) { | 337 if (window_->parent()) { |
338 ServerChangeData data; | 338 ServerChangeData data; |
339 data.child_id = server_id(); | 339 data.child_id = server_id(); |
340 WindowPortMus* parent = Get(window_->parent()); | 340 WindowPortMus* parent = Get(window_->parent()); |
341 remove_from_parent_change = base::MakeUnique<ScopedServerChange>( | 341 remove_from_parent_change = base::MakeUnique<ScopedServerChange>( |
342 parent, ServerChangeType::REMOVE, data); | 342 parent, ServerChangeType::REMOVE, data); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 change_data) == server_changes_.end()) { | 470 change_data) == server_changes_.end()) { |
471 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); | 471 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 void WindowPortMus::OnVisibilityChanged(bool visible) { | 475 void WindowPortMus::OnVisibilityChanged(bool visible) { |
476 ServerChangeData change_data; | 476 ServerChangeData change_data; |
477 change_data.visible = visible; | 477 change_data.visible = visible; |
478 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) | 478 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) |
479 window_tree_client_->OnWindowMusSetVisible(this, visible); | 479 window_tree_client_->OnWindowMusSetVisible(this, visible); |
480 // We should only embed a client if its visible. | |
481 UpdateClientSurfaceEmbedder(); | |
482 } | 480 } |
483 | 481 |
484 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, | 482 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, |
485 const gfx::Rect& new_bounds) { | 483 const gfx::Rect& new_bounds) { |
486 ServerChangeData change_data; | 484 ServerChangeData change_data; |
487 change_data.bounds_in_dip = new_bounds; | 485 change_data.bounds_in_dip = new_bounds; |
488 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data)) | 486 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data)) |
489 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds); | 487 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds); |
| 488 if (client_surface_embedder_) |
| 489 client_surface_embedder_->UpdateSizeAndGutters(); |
490 } | 490 } |
491 | 491 |
492 std::unique_ptr<ui::PropertyData> WindowPortMus::OnWillChangeProperty( | 492 std::unique_ptr<ui::PropertyData> WindowPortMus::OnWillChangeProperty( |
493 const void* key) { | 493 const void* key) { |
494 // |window_| is null if a property is set on the aura::Window before | 494 // |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 | 495 // 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 | 496 // once Window::Init() is called the Window is queried for the current set of |
497 // properties. | 497 // properties. |
498 if (!window_) | 498 if (!window_) |
499 return nullptr; | 499 return nullptr; |
(...skipping 29 matching lines...) Expand all Loading... |
529 return; | 529 return; |
530 | 530 |
531 primary_surface_info_ = | 531 primary_surface_info_ = |
532 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_), | 532 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_), |
533 ScaleFactorForDisplay(window_), last_surface_size_); | 533 ScaleFactorForDisplay(window_), last_surface_size_); |
534 | 534 |
535 UpdateClientSurfaceEmbedder(); | 535 UpdateClientSurfaceEmbedder(); |
536 } | 536 } |
537 | 537 |
538 void WindowPortMus::UpdateClientSurfaceEmbedder() { | 538 void WindowPortMus::UpdateClientSurfaceEmbedder() { |
539 if (!client_surface_embedder_ && primary_surface_info_.is_valid()) | 539 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
540 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(window_); | 540 window_mus_type() == WindowMusType::EMBED_IN_OWNER; |
| 541 if (!embeds_surface) |
| 542 return; |
541 | 543 |
542 if (primary_surface_info_.is_valid() && window_->IsVisible()) | 544 if (!client_surface_embedder_) { |
543 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); | 545 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( |
544 else | 546 window_, window_tree_client_->normal_client_area_insets_); |
545 client_surface_embedder_.reset(); | 547 } |
| 548 |
| 549 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); |
| 550 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); |
546 } | 551 } |
547 | 552 |
548 } // namespace aura | 553 } // namespace aura |
OLD | NEW |