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

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

Issue 2764433003: mus-ws: Plumb FrameSinkId to Children (Closed)
Patch Set: Addressed Antoine's comment Created 3 years, 9 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void WindowTreeClient::SetLocalPropertiesFromServerProperties( 432 void WindowTreeClient::SetLocalPropertiesFromServerProperties(
433 WindowMus* window, 433 WindowMus* window,
434 const ui::mojom::WindowData& window_data) { 434 const ui::mojom::WindowData& window_data) {
435 for (auto& pair : window_data.properties) 435 for (auto& pair : window_data.properties)
436 window->SetPropertyFromServer(pair.first, &pair.second); 436 window->SetPropertyFromServer(pair.first, &pair.second);
437 } 437 }
438 438
439 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost( 439 std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
440 WindowMusType window_mus_type, 440 WindowMusType window_mus_type,
441 const ui::mojom::WindowData& window_data, 441 const ui::mojom::WindowData& window_data,
442 int64_t display_id) { 442 int64_t display_id,
443 const cc::FrameSinkId& frame_sink_id) {
443 std::unique_ptr<WindowPortMus> window_port = 444 std::unique_ptr<WindowPortMus> window_port =
444 CreateWindowPortMus(window_data, window_mus_type); 445 CreateWindowPortMus(window_data, window_mus_type);
445 roots_.insert(window_port.get()); 446 roots_.insert(window_port.get());
446 std::unique_ptr<WindowTreeHostMus> window_tree_host = 447 std::unique_ptr<WindowTreeHostMus> window_tree_host =
447 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this, 448 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this,
448 display_id); 449 display_id, frame_sink_id);
449 window_tree_host->InitHost(); 450 window_tree_host->InitHost();
450 SetLocalPropertiesFromServerProperties( 451 SetLocalPropertiesFromServerProperties(
451 WindowMus::Get(window_tree_host->window()), window_data); 452 WindowMus::Get(window_tree_host->window()), window_data);
452 if (window_data.visible) { 453 if (window_data.visible) {
453 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()), 454 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()),
454 true); 455 true);
455 } 456 }
456 SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()), 457 SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()),
457 window_data.bounds); 458 window_data.bounds);
458 return window_tree_host; 459 return window_tree_host;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 tree_->SetModalType(change_id, window->server_id(), 528 tree_->SetModalType(change_id, window->server_id(),
528 window->GetWindow()->GetProperty(client::kModalKey)); 529 window->GetWindow()->GetProperty(client::kModalKey));
529 return true; 530 return true;
530 } 531 }
531 532
532 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree, 533 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree,
533 ClientSpecificId client_id, 534 ClientSpecificId client_id,
534 ui::mojom::WindowDataPtr root_data, 535 ui::mojom::WindowDataPtr root_data,
535 int64_t display_id, 536 int64_t display_id,
536 Id focused_window_id, 537 Id focused_window_id,
537 bool drawn) { 538 bool drawn,
539 const cc::FrameSinkId& frame_sink_id) {
538 // WARNING: this is only called if WindowTreeClient was created as the 540 // WARNING: this is only called if WindowTreeClient was created as the
539 // result of an embedding. 541 // result of an embedding.
540 client_id_ = client_id; 542 client_id_ = client_id;
541 WindowTreeConnectionEstablished(window_tree); 543 WindowTreeConnectionEstablished(window_tree);
542 544
543 DCHECK(roots_.empty()); 545 DCHECK(roots_.empty());
544 std::unique_ptr<WindowTreeHostMus> window_tree_host = 546 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost(
545 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id); 547 WindowMusType::EMBED, *root_data, display_id, frame_sink_id);
546 548
547 focus_synchronizer_->SetFocusFromServer( 549 focus_synchronizer_->SetFocusFromServer(
548 GetWindowByServerId(focused_window_id)); 550 GetWindowByServerId(focused_window_id));
549 551
550 delegate_->OnEmbed(std::move(window_tree_host)); 552 delegate_->OnEmbed(std::move(window_tree_host));
551 } 553 }
552 554
553 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( 555 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
554 const display::Display& display, 556 const display::Display& display,
555 ui::mojom::WindowDataPtr root_data, 557 ui::mojom::WindowDataPtr root_data,
556 bool parent_drawn) { 558 bool parent_drawn,
559 const cc::FrameSinkId& frame_sink_id) {
557 DCHECK(window_manager_delegate_); 560 DCHECK(window_manager_delegate_);
558 561
559 window_manager_delegate_->OnWmWillCreateDisplay(display); 562 window_manager_delegate_->OnWmWillCreateDisplay(display);
560 563
561 std::unique_ptr<WindowTreeHostMus> window_tree_host = 564 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost(
562 CreateWindowTreeHost(WindowMusType::DISPLAY, *root_data, display.id()); 565 WindowMusType::DISPLAY, *root_data, display.id(), frame_sink_id);
563 566
564 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get(); 567 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
565 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host), 568 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
566 display); 569 display);
567 return window_tree_host_ptr; 570 return window_tree_host_ptr;
568 } 571 }
569 572
570 std::unique_ptr<EventResultCallback> 573 std::unique_ptr<EventResultCallback>
571 WindowTreeClient::CreateEventResultCallback(int32_t event_id) { 574 WindowTreeClient::CreateEventResultCallback(int32_t event_id) {
572 return base::MakeUnique<EventResultCallback>( 575 return base::MakeUnique<EventResultCallback>(
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 ui::mojom::EventTargetingPolicy policy) { 873 ui::mojom::EventTargetingPolicy policy) {
871 DCHECK(tree_); 874 DCHECK(tree_);
872 tree_->SetEventTargetingPolicy(window->server_id(), policy); 875 tree_->SetEventTargetingPolicy(window->server_id(), policy);
873 } 876 }
874 877
875 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, 878 void WindowTreeClient::OnEmbed(ClientSpecificId client_id,
876 ui::mojom::WindowDataPtr root_data, 879 ui::mojom::WindowDataPtr root_data,
877 ui::mojom::WindowTreePtr tree, 880 ui::mojom::WindowTreePtr tree,
878 int64_t display_id, 881 int64_t display_id,
879 Id focused_window_id, 882 Id focused_window_id,
880 bool drawn) { 883 bool drawn,
884 const cc::FrameSinkId& frame_sink_id) {
881 DCHECK(!tree_ptr_); 885 DCHECK(!tree_ptr_);
882 tree_ptr_ = std::move(tree); 886 tree_ptr_ = std::move(tree);
883 887
884 is_from_embed_ = true; 888 is_from_embed_ = true;
885 889
886 if (window_manager_delegate_) { 890 if (window_manager_delegate_) {
887 tree_ptr_->GetWindowManagerClient( 891 tree_ptr_->GetWindowManagerClient(
888 MakeRequest(&window_manager_internal_client_)); 892 MakeRequest(&window_manager_internal_client_));
889 } 893 }
890 894
891 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, 895 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id,
892 focused_window_id, drawn); 896 focused_window_id, drawn, frame_sink_id);
893 } 897 }
894 898
895 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) { 899 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) {
896 WindowMus* window = GetWindowByServerId(window_id); 900 WindowMus* window = GetWindowByServerId(window_id);
897 if (window) 901 if (window)
898 window->NotifyEmbeddedAppDisconnected(); 902 window->NotifyEmbeddedAppDisconnected();
899 } 903 }
900 904
901 void WindowTreeClient::OnUnembed(Id window_id) { 905 void WindowTreeClient::OnUnembed(Id window_id) {
902 WindowMus* window = GetWindowByServerId(window_id); 906 WindowMus* window = GetWindowByServerId(window_id);
(...skipping 15 matching lines...) Expand all
918 new_capture_window); 922 new_capture_window);
919 if (ApplyServerChangeToExistingInFlightChange(change)) 923 if (ApplyServerChangeToExistingInFlightChange(change))
920 return; 924 return;
921 925
922 capture_synchronizer_->SetCaptureFromServer(new_capture_window); 926 capture_synchronizer_->SetCaptureFromServer(new_capture_window);
923 } 927 }
924 928
925 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, 929 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
926 ui::mojom::WindowDataPtr data, 930 ui::mojom::WindowDataPtr data,
927 int64_t display_id, 931 int64_t display_id,
928 bool drawn) { 932 bool drawn,
933 const cc::FrameSinkId& frame_sink_id) {
929 // The server ack'd the top level window we created and supplied the state 934 // The server ack'd the top level window we created and supplied the state
930 // of the window at the time the server created it. For properties we do not 935 // of the window at the time the server created it. For properties we do not
931 // have changes in flight for we can update them immediately. For properties 936 // have changes in flight for we can update them immediately. For properties
932 // with changes in flight we set the revert value from the server. 937 // with changes in flight we set the revert value from the server.
933 938
934 if (!in_flight_map_.count(change_id)) { 939 if (!in_flight_map_.count(change_id)) {
935 // The window may have been destroyed locally before the server could finish 940 // The window may have been destroyed locally before the server could finish
936 // creating the window, and before the server received the notification that 941 // creating the window, and before the server received the notification that
937 // the window has been destroyed. 942 // the window has been destroyed.
938 return; 943 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 GetOldestInFlightChangeMatching(property_change); 987 GetOldestInFlightChangeMatching(property_change);
983 if (current_change) { 988 if (current_change) {
984 current_change->SetRevertValueFrom(property_change); 989 current_change->SetRevertValueFrom(property_change);
985 } else { 990 } else {
986 window->SetPropertyFromServer(pair.first, &pair.second); 991 window->SetPropertyFromServer(pair.first, &pair.second);
987 } 992 }
988 } 993 }
989 994
990 // Top level windows should not have a parent. 995 // Top level windows should not have a parent.
991 DCHECK_EQ(0u, data->parent_id); 996 DCHECK_EQ(0u, data->parent_id);
997
998 window->SetFrameSinkIdFromServer(frame_sink_id);
992 } 999 }
993 1000
994 void WindowTreeClient::OnWindowBoundsChanged( 1001 void WindowTreeClient::OnWindowBoundsChanged(
995 Id window_id, 1002 Id window_id,
996 const gfx::Rect& old_bounds, 1003 const gfx::Rect& old_bounds,
997 const gfx::Rect& new_bounds, 1004 const gfx::Rect& new_bounds,
998 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { 1005 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
999 WindowMus* window = GetWindowByServerId(window_id); 1006 WindowMus* window = GetWindowByServerId(window_id);
1000 if (!window) 1007 if (!window)
1001 return; 1008 return;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 // WindowTreeHost. 1357 // WindowTreeHost.
1351 GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest(); 1358 GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest();
1352 } 1359 }
1353 1360
1354 void WindowTreeClient::OnConnect(ClientSpecificId client_id) { 1361 void WindowTreeClient::OnConnect(ClientSpecificId client_id) {
1355 client_id_ = client_id; 1362 client_id_ = client_id;
1356 } 1363 }
1357 1364
1358 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, 1365 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display,
1359 ui::mojom::WindowDataPtr root_data, 1366 ui::mojom::WindowDataPtr root_data,
1360 bool parent_drawn) { 1367 bool parent_drawn,
1361 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn); 1368 const cc::FrameSinkId& frame_sink_id) {
1369 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn,
1370 frame_sink_id);
1362 } 1371 }
1363 1372
1364 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { 1373 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) {
1365 DCHECK(window_manager_delegate_); 1374 DCHECK(window_manager_delegate_);
1366 for (WindowMus* root : roots_) { 1375 for (WindowMus* root : roots_) {
1367 DCHECK(root->GetWindow()->GetHost()); 1376 DCHECK(root->GetWindow()->GetHost());
1368 WindowTreeHostMus* window_tree_host = 1377 WindowTreeHostMus* window_tree_host =
1369 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); 1378 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost());
1370 if (window_tree_host->display_id() == display_id) { 1379 if (window_tree_host->display_id() == display_id) {
1371 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); 1380 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1875 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1867 this, capture_synchronizer_.get(), window)); 1876 this, capture_synchronizer_.get(), window));
1868 } 1877 }
1869 1878
1870 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1879 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1871 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1880 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1872 this, focus_synchronizer_.get(), window)); 1881 this, focus_synchronizer_.get(), window));
1873 } 1882 }
1874 1883
1875 } // namespace aura 1884 } // 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