Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2886873002: Only send the FrameSinkId to client when it is necessary (Closed)
Patch Set: Address review issues. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 WindowMus* window, 462 WindowMus* window,
463 const ui::mojom::WindowData& window_data) { 463 const ui::mojom::WindowData& window_data) {
464 for (auto& pair : window_data.properties) 464 for (auto& pair : window_data.properties)
465 window->SetPropertyFromServer(pair.first, &pair.second); 465 window->SetPropertyFromServer(pair.first, &pair.second);
466 } 466 }
467 467
468 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost( 468 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
469 WindowMusType window_mus_type, 469 WindowMusType window_mus_type,
470 const ui::mojom::WindowData& window_data, 470 const ui::mojom::WindowData& window_data,
471 int64_t display_id, 471 int64_t display_id,
472 const cc::FrameSinkId& frame_sink_id,
473 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 472 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
474 std::unique_ptr<WindowPortMus> window_port = 473 std::unique_ptr<WindowPortMus> window_port =
475 CreateWindowPortMus(window_data, window_mus_type); 474 CreateWindowPortMus(window_data, window_mus_type);
476 roots_.insert(window_port.get()); 475 roots_.insert(window_port.get());
477 WindowTreeHostMusInitParams init_params; 476 WindowTreeHostMusInitParams init_params;
478 init_params.window_port = std::move(window_port); 477 init_params.window_port = std::move(window_port);
479 init_params.window_tree_client = this; 478 init_params.window_tree_client = this;
480 init_params.display_id = display_id; 479 init_params.display_id = display_id;
481 init_params.frame_sink_id = frame_sink_id;
482 std::unique_ptr<WindowTreeHostMus> window_tree_host = 480 std::unique_ptr<WindowTreeHostMus> window_tree_host =
483 base::MakeUnique<WindowTreeHostMus>(std::move(init_params)); 481 base::MakeUnique<WindowTreeHostMus>(std::move(init_params));
484 window_tree_host->InitHost(); 482 window_tree_host->InitHost();
485 SetLocalPropertiesFromServerProperties( 483 SetLocalPropertiesFromServerProperties(
486 WindowMus::Get(window_tree_host->window()), window_data); 484 WindowMus::Get(window_tree_host->window()), window_data);
487 if (window_data.visible) { 485 if (window_data.visible) {
488 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()), 486 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()),
489 true); 487 true);
490 } 488 }
491 WindowMus* window = WindowMus::Get(window_tree_host->window()); 489 WindowMus* window = WindowMus::Get(window_tree_host->window());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 return true; 562 return true;
565 } 563 }
566 564
567 void WindowTreeClient::OnEmbedImpl( 565 void WindowTreeClient::OnEmbedImpl(
568 ui::mojom::WindowTree* window_tree, 566 ui::mojom::WindowTree* window_tree,
569 ClientSpecificId client_id, 567 ClientSpecificId client_id,
570 ui::mojom::WindowDataPtr root_data, 568 ui::mojom::WindowDataPtr root_data,
571 int64_t display_id, 569 int64_t display_id,
572 Id focused_window_id, 570 Id focused_window_id,
573 bool drawn, 571 bool drawn,
574 const cc::FrameSinkId& frame_sink_id,
575 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 572 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
576 // WARNING: this is only called if WindowTreeClient was created as the 573 // WARNING: this is only called if WindowTreeClient was created as the
577 // result of an embedding. 574 // result of an embedding.
578 client_id_ = client_id; 575 client_id_ = client_id;
579 WindowTreeConnectionEstablished(window_tree); 576 WindowTreeConnectionEstablished(window_tree);
580 577
581 DCHECK(roots_.empty()); 578 DCHECK(roots_.empty());
582 std::unique_ptr<WindowTreeHostMus> window_tree_host = 579 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost(
583 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id, 580 WindowMusType::EMBED, *root_data, display_id, local_surface_id);
584 frame_sink_id, local_surface_id);
585 581
586 focus_synchronizer_->SetFocusFromServer( 582 focus_synchronizer_->SetFocusFromServer(
587 GetWindowByServerId(focused_window_id)); 583 GetWindowByServerId(focused_window_id));
588 584
589 delegate_->OnEmbed(std::move(window_tree_host)); 585 delegate_->OnEmbed(std::move(window_tree_host));
590 } 586 }
591 587
592 void WindowTreeClient::OnSetDisplayRootDone( 588 void WindowTreeClient::OnSetDisplayRootDone(bool success) {
593 Id window_id,
594 const base::Optional<cc::FrameSinkId>& frame_sink_id) {
595 // The only way SetDisplayRoot() should fail is if we've done something wrong. 589 // The only way SetDisplayRoot() should fail is if we've done something wrong.
596 CHECK(frame_sink_id); 590 CHECK(success);
597
598 WindowMus* window = GetWindowByServerId(window_id);
599 if (!window)
600 return; // Display was already deleted.
601
602 window->SetFrameSinkIdFromServer(*frame_sink_id);
603 } 591 }
604 592
605 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( 593 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
606 const display::Display& display, 594 const display::Display& display,
607 ui::mojom::WindowDataPtr root_data, 595 ui::mojom::WindowDataPtr root_data,
608 bool parent_drawn, 596 bool parent_drawn,
609 const cc::FrameSinkId& frame_sink_id,
610 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 597 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
611 DCHECK(window_manager_delegate_); 598 DCHECK(window_manager_delegate_);
612 599
613 got_initial_displays_ = true; 600 got_initial_displays_ = true;
614 601
615 window_manager_delegate_->OnWmWillCreateDisplay(display); 602 window_manager_delegate_->OnWmWillCreateDisplay(display);
616 603
617 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost( 604 std::unique_ptr<WindowTreeHostMus> window_tree_host =
618 WindowMusType::DISPLAY_AUTOMATICALLY_CREATED, *root_data, display.id(), 605 CreateWindowTreeHost(WindowMusType::DISPLAY_AUTOMATICALLY_CREATED,
619 frame_sink_id, local_surface_id); 606 *root_data, display.id(), local_surface_id);
620 607
621 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get(); 608 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
622 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host), 609 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
623 display); 610 display);
624 return window_tree_host_ptr; 611 return window_tree_host_ptr;
625 } 612 }
626 613
627 std::unique_ptr<EventResultCallback> 614 std::unique_ptr<EventResultCallback>
628 WindowTreeClient::CreateEventResultCallback(int32_t event_id) { 615 WindowTreeClient::CreateEventResultCallback(int32_t event_id) {
629 return base::MakeUnique<EventResultCallback>( 616 return base::MakeUnique<EventResultCallback>(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 ScheduleInFlightBoundsChange( 728 ScheduleInFlightBoundsChange(
742 window, gfx::Rect(), 729 window, gfx::Rect(),
743 gfx::Rect( 730 gfx::Rect(
744 display_init_params->viewport_metrics.bounds_in_pixels.size())); 731 display_init_params->viewport_metrics.bounds_in_pixels.size()));
745 732
746 if (window_manager_client_) { 733 if (window_manager_client_) {
747 window_manager_client_->SetDisplayRoot( 734 window_manager_client_->SetDisplayRoot(
748 display, display_init_params->viewport_metrics.Clone(), 735 display, display_init_params->viewport_metrics.Clone(),
749 display_init_params->is_primary_display, window->server_id(), 736 display_init_params->is_primary_display, window->server_id(),
750 base::Bind(&WindowTreeClient::OnSetDisplayRootDone, 737 base::Bind(&WindowTreeClient::OnSetDisplayRootDone,
751 base::Unretained(this), window->server_id())); 738 base::Unretained(this)));
752 } 739 }
753 } 740 }
754 } 741 }
755 742
756 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { 743 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
757 if (focus_synchronizer_->focused_window() == window) 744 if (focus_synchronizer_->focused_window() == window)
758 focus_synchronizer_->OnFocusedWindowDestroyed(); 745 focus_synchronizer_->OnFocusedWindowDestroyed();
759 746
760 // TODO: decide how to deal with windows not owned by this client. 747 // TODO: decide how to deal with windows not owned by this client.
761 if (origin == Origin::CLIENT && 748 if (origin == Origin::CLIENT &&
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 tree_->SetEventTargetingPolicy(window->server_id(), policy); 964 tree_->SetEventTargetingPolicy(window->server_id(), policy);
978 } 965 }
979 966
980 void WindowTreeClient::OnEmbed( 967 void WindowTreeClient::OnEmbed(
981 ClientSpecificId client_id, 968 ClientSpecificId client_id,
982 ui::mojom::WindowDataPtr root_data, 969 ui::mojom::WindowDataPtr root_data,
983 ui::mojom::WindowTreePtr tree, 970 ui::mojom::WindowTreePtr tree,
984 int64_t display_id, 971 int64_t display_id,
985 Id focused_window_id, 972 Id focused_window_id,
986 bool drawn, 973 bool drawn,
987 const cc::FrameSinkId& frame_sink_id,
988 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 974 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
989 DCHECK(!tree_ptr_); 975 DCHECK(!tree_ptr_);
990 tree_ptr_ = std::move(tree); 976 tree_ptr_ = std::move(tree);
991 977
992 is_from_embed_ = true; 978 is_from_embed_ = true;
993 979
994 if (window_manager_delegate_) { 980 if (window_manager_delegate_) {
995 tree_ptr_->GetWindowManagerClient( 981 tree_ptr_->GetWindowManagerClient(
996 MakeRequest(&window_manager_internal_client_)); 982 MakeRequest(&window_manager_internal_client_));
997 window_manager_client_ = window_manager_internal_client_.get(); 983 window_manager_client_ = window_manager_internal_client_.get();
998 } 984 }
999 985
1000 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, 986 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id,
1001 focused_window_id, drawn, frame_sink_id, local_surface_id); 987 focused_window_id, drawn, local_surface_id);
1002 } 988 }
1003 989
1004 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) { 990 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) {
1005 WindowMus* window = GetWindowByServerId(window_id); 991 WindowMus* window = GetWindowByServerId(window_id);
1006 if (window) 992 if (window)
1007 window->NotifyEmbeddedAppDisconnected(); 993 window->NotifyEmbeddedAppDisconnected();
1008 } 994 }
1009 995
1010 void WindowTreeClient::OnUnembed(Id window_id) { 996 void WindowTreeClient::OnUnembed(Id window_id) {
1011 WindowMus* window = GetWindowByServerId(window_id); 997 WindowMus* window = GetWindowByServerId(window_id);
(...skipping 27 matching lines...) Expand all
1039 return; 1025 return;
1040 1026
1041 window->SetFrameSinkIdFromServer(frame_sink_id); 1027 window->SetFrameSinkIdFromServer(frame_sink_id);
1042 } 1028 }
1043 1029
1044 void WindowTreeClient::OnTopLevelCreated( 1030 void WindowTreeClient::OnTopLevelCreated(
1045 uint32_t change_id, 1031 uint32_t change_id,
1046 ui::mojom::WindowDataPtr data, 1032 ui::mojom::WindowDataPtr data,
1047 int64_t display_id, 1033 int64_t display_id,
1048 bool drawn, 1034 bool drawn,
1049 const cc::FrameSinkId& frame_sink_id,
1050 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 1035 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
1051 // The server ack'd the top level window we created and supplied the state 1036 // The server ack'd the top level window we created and supplied the state
1052 // of the window at the time the server created it. For properties we do not 1037 // of the window at the time the server created it. For properties we do not
1053 // have changes in flight for we can update them immediately. For properties 1038 // have changes in flight for we can update them immediately. For properties
1054 // with changes in flight we set the revert value from the server. 1039 // with changes in flight we set the revert value from the server.
1055 1040
1056 if (!in_flight_map_.count(change_id)) { 1041 if (!in_flight_map_.count(change_id)) {
1057 // The window may have been destroyed locally before the server could finish 1042 // The window may have been destroyed locally before the server could finish
1058 // creating the window, and before the server received the notification that 1043 // creating the window, and before the server received the notification that
1059 // the window has been destroyed. 1044 // the window has been destroyed.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 GetOldestInFlightChangeMatching(property_change); 1090 GetOldestInFlightChangeMatching(property_change);
1106 if (current_change) { 1091 if (current_change) {
1107 current_change->SetRevertValueFrom(property_change); 1092 current_change->SetRevertValueFrom(property_change);
1108 } else { 1093 } else {
1109 window->SetPropertyFromServer(pair.first, &pair.second); 1094 window->SetPropertyFromServer(pair.first, &pair.second);
1110 } 1095 }
1111 } 1096 }
1112 1097
1113 // Top level windows should not have a parent. 1098 // Top level windows should not have a parent.
1114 DCHECK_EQ(0u, data->parent_id); 1099 DCHECK_EQ(0u, data->parent_id);
1115
1116 window->SetFrameSinkIdFromServer(frame_sink_id);
1117 } 1100 }
1118 1101
1119 void WindowTreeClient::OnWindowBoundsChanged( 1102 void WindowTreeClient::OnWindowBoundsChanged(
1120 Id window_id, 1103 Id window_id,
1121 const gfx::Rect& old_bounds, 1104 const gfx::Rect& old_bounds,
1122 const gfx::Rect& new_bounds, 1105 const gfx::Rect& new_bounds,
1123 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 1106 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
1124 WindowMus* window = GetWindowByServerId(window_id); 1107 WindowMus* window = GetWindowByServerId(window_id);
1125 if (!window) 1108 if (!window)
1126 return; 1109 return;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 client_id_ = client_id; 1488 client_id_ = client_id;
1506 got_initial_displays_ = true; 1489 got_initial_displays_ = true;
1507 if (window_manager_delegate_) 1490 if (window_manager_delegate_)
1508 window_manager_delegate_->OnWmConnected(); 1491 window_manager_delegate_->OnWmConnected();
1509 } 1492 }
1510 1493
1511 void WindowTreeClient::WmNewDisplayAdded( 1494 void WindowTreeClient::WmNewDisplayAdded(
1512 const display::Display& display, 1495 const display::Display& display,
1513 ui::mojom::WindowDataPtr root_data, 1496 ui::mojom::WindowDataPtr root_data,
1514 bool parent_drawn, 1497 bool parent_drawn,
1515 const cc::FrameSinkId& frame_sink_id,
1516 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 1498 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
1517 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn, 1499 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn,
1518 frame_sink_id, local_surface_id); 1500 local_surface_id);
1519 } 1501 }
1520 1502
1521 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { 1503 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) {
1522 DCHECK(window_manager_delegate_); 1504 DCHECK(window_manager_delegate_);
1523 for (WindowMus* root : roots_) { 1505 for (WindowMus* root : roots_) {
1524 DCHECK(root->GetWindow()->GetHost()); 1506 DCHECK(root->GetWindow()->GetHost());
1525 WindowTreeHostMus* window_tree_host = 1507 WindowTreeHostMus* window_tree_host =
1526 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); 1508 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost());
1527 if (window_tree_host->display_id() == display_id) { 1509 if (window_tree_host->display_id() == display_id) {
1528 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); 1510 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host);
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 } 2079 }
2098 2080
2099 void WindowTreeClient::OnCompositingLockStateChanged( 2081 void WindowTreeClient::OnCompositingLockStateChanged(
2100 ui::Compositor* compositor) {} 2082 ui::Compositor* compositor) {}
2101 2083
2102 void WindowTreeClient::OnCompositingShuttingDown(ui::Compositor* compositor) { 2084 void WindowTreeClient::OnCompositingShuttingDown(ui::Compositor* compositor) {
2103 compositor->RemoveObserver(this); 2085 compositor->RemoveObserver(this);
2104 } 2086 }
2105 2087
2106 } // namespace aura 2088 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698