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

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

Issue 2778363002: Mus-WS / Aura-Mus: Propagate LocalSurfaceId on WindowTreeHost creation (Closed)
Patch Set: Add comments Created 3 years, 8 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const cc::FrameSinkId& frame_sink_id,
444 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
444 std::unique_ptr<WindowPortMus> window_port = 445 std::unique_ptr<WindowPortMus> window_port =
445 CreateWindowPortMus(window_data, window_mus_type); 446 CreateWindowPortMus(window_data, window_mus_type);
446 roots_.insert(window_port.get()); 447 roots_.insert(window_port.get());
447 std::unique_ptr<WindowTreeHostMus> window_tree_host = 448 std::unique_ptr<WindowTreeHostMus> window_tree_host =
448 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this, 449 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this,
449 display_id, frame_sink_id); 450 display_id, frame_sink_id);
450 window_tree_host->InitHost(); 451 window_tree_host->InitHost();
451 SetLocalPropertiesFromServerProperties( 452 SetLocalPropertiesFromServerProperties(
452 WindowMus::Get(window_tree_host->window()), window_data); 453 WindowMus::Get(window_tree_host->window()), window_data);
453 if (window_data.visible) { 454 if (window_data.visible) {
454 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()), 455 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()),
455 true); 456 true);
456 } 457 }
457 SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()), 458 WindowMus* window = WindowMus::Get(window_tree_host->window());
458 window_data.bounds, base::nullopt); 459
460 SetWindowBoundsFromServer(window, window_data.bounds, local_surface_id);
459 return window_tree_host; 461 return window_tree_host;
460 } 462 }
461 463
462 WindowMus* WindowTreeClient::NewWindowFromWindowData( 464 WindowMus* WindowTreeClient::NewWindowFromWindowData(
463 WindowMus* parent, 465 WindowMus* parent,
464 const ui::mojom::WindowData& window_data) { 466 const ui::mojom::WindowData& window_data) {
465 // This function is only called for windows coming from other clients. 467 // This function is only called for windows coming from other clients.
466 std::unique_ptr<WindowPortMus> window_port_mus( 468 std::unique_ptr<WindowPortMus> window_port_mus(
467 CreateWindowPortMus(window_data, WindowMusType::OTHER)); 469 CreateWindowPortMus(window_data, WindowMusType::OTHER));
468 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); 470 WindowPortMus* window_port_mus_ptr = window_port_mus.get();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return false; 519 return false;
518 520
519 const uint32_t change_id = 521 const uint32_t change_id =
520 ScheduleInFlightChange(base::MakeUnique<InFlightSetModalTypeChange>( 522 ScheduleInFlightChange(base::MakeUnique<InFlightSetModalTypeChange>(
521 window, static_cast<ui::ModalType>(old_value))); 523 window, static_cast<ui::ModalType>(old_value)));
522 tree_->SetModalType(change_id, window->server_id(), 524 tree_->SetModalType(change_id, window->server_id(),
523 window->GetWindow()->GetProperty(client::kModalKey)); 525 window->GetWindow()->GetProperty(client::kModalKey));
524 return true; 526 return true;
525 } 527 }
526 528
527 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree, 529 void WindowTreeClient::OnEmbedImpl(
528 ClientSpecificId client_id, 530 ui::mojom::WindowTree* window_tree,
529 ui::mojom::WindowDataPtr root_data, 531 ClientSpecificId client_id,
530 int64_t display_id, 532 ui::mojom::WindowDataPtr root_data,
531 Id focused_window_id, 533 int64_t display_id,
532 bool drawn, 534 Id focused_window_id,
533 const cc::FrameSinkId& frame_sink_id) { 535 bool drawn,
536 const cc::FrameSinkId& frame_sink_id,
537 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
534 // WARNING: this is only called if WindowTreeClient was created as the 538 // WARNING: this is only called if WindowTreeClient was created as the
535 // result of an embedding. 539 // result of an embedding.
536 client_id_ = client_id; 540 client_id_ = client_id;
537 WindowTreeConnectionEstablished(window_tree); 541 WindowTreeConnectionEstablished(window_tree);
538 542
539 DCHECK(roots_.empty()); 543 DCHECK(roots_.empty());
540 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost( 544 std::unique_ptr<WindowTreeHostMus> window_tree_host =
541 WindowMusType::EMBED, *root_data, display_id, frame_sink_id); 545 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id,
546 frame_sink_id, local_surface_id);
542 547
543 focus_synchronizer_->SetFocusFromServer( 548 focus_synchronizer_->SetFocusFromServer(
544 GetWindowByServerId(focused_window_id)); 549 GetWindowByServerId(focused_window_id));
545 550
546 delegate_->OnEmbed(std::move(window_tree_host)); 551 delegate_->OnEmbed(std::move(window_tree_host));
547 } 552 }
548 553
549 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( 554 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
550 const display::Display& display, 555 const display::Display& display,
551 ui::mojom::WindowDataPtr root_data, 556 ui::mojom::WindowDataPtr root_data,
552 bool parent_drawn, 557 bool parent_drawn,
553 const cc::FrameSinkId& frame_sink_id) { 558 const cc::FrameSinkId& frame_sink_id,
559 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
554 DCHECK(window_manager_delegate_); 560 DCHECK(window_manager_delegate_);
555 561
556 got_initial_displays_ = true; 562 got_initial_displays_ = true;
557 563
558 window_manager_delegate_->OnWmWillCreateDisplay(display); 564 window_manager_delegate_->OnWmWillCreateDisplay(display);
559 565
560 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost( 566 std::unique_ptr<WindowTreeHostMus> window_tree_host =
561 WindowMusType::DISPLAY, *root_data, display.id(), frame_sink_id); 567 CreateWindowTreeHost(WindowMusType::DISPLAY, *root_data, display.id(),
568 frame_sink_id, local_surface_id);
562 569
563 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get(); 570 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
564 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host), 571 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
565 display); 572 display);
566 return window_tree_host_ptr; 573 return window_tree_host_ptr;
567 } 574 }
568 575
569 std::unique_ptr<EventResultCallback> 576 std::unique_ptr<EventResultCallback>
570 WindowTreeClient::CreateEventResultCallback(int32_t event_id) { 577 WindowTreeClient::CreateEventResultCallback(int32_t event_id) {
571 return base::MakeUnique<EventResultCallback>( 578 return base::MakeUnique<EventResultCallback>(
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 tree_->SetCanAcceptDrops(window->server_id(), can_accept_drops); 874 tree_->SetCanAcceptDrops(window->server_id(), can_accept_drops);
868 } 875 }
869 876
870 void WindowTreeClient::SetEventTargetingPolicy( 877 void WindowTreeClient::SetEventTargetingPolicy(
871 WindowMus* window, 878 WindowMus* window,
872 ui::mojom::EventTargetingPolicy policy) { 879 ui::mojom::EventTargetingPolicy policy) {
873 DCHECK(tree_); 880 DCHECK(tree_);
874 tree_->SetEventTargetingPolicy(window->server_id(), policy); 881 tree_->SetEventTargetingPolicy(window->server_id(), policy);
875 } 882 }
876 883
877 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, 884 void WindowTreeClient::OnEmbed(
878 ui::mojom::WindowDataPtr root_data, 885 ClientSpecificId client_id,
879 ui::mojom::WindowTreePtr tree, 886 ui::mojom::WindowDataPtr root_data,
880 int64_t display_id, 887 ui::mojom::WindowTreePtr tree,
881 Id focused_window_id, 888 int64_t display_id,
882 bool drawn, 889 Id focused_window_id,
883 const cc::FrameSinkId& frame_sink_id) { 890 bool drawn,
891 const cc::FrameSinkId& frame_sink_id,
892 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
884 DCHECK(!tree_ptr_); 893 DCHECK(!tree_ptr_);
885 tree_ptr_ = std::move(tree); 894 tree_ptr_ = std::move(tree);
886 895
887 is_from_embed_ = true; 896 is_from_embed_ = true;
888 897
889 if (window_manager_delegate_) { 898 if (window_manager_delegate_) {
890 tree_ptr_->GetWindowManagerClient( 899 tree_ptr_->GetWindowManagerClient(
891 MakeRequest(&window_manager_internal_client_)); 900 MakeRequest(&window_manager_internal_client_));
892 } 901 }
893 902
894 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, 903 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id,
895 focused_window_id, drawn, frame_sink_id); 904 focused_window_id, drawn, frame_sink_id, local_surface_id);
896 } 905 }
897 906
898 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) { 907 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) {
899 WindowMus* window = GetWindowByServerId(window_id); 908 WindowMus* window = GetWindowByServerId(window_id);
900 if (window) 909 if (window)
901 window->NotifyEmbeddedAppDisconnected(); 910 window->NotifyEmbeddedAppDisconnected();
902 } 911 }
903 912
904 void WindowTreeClient::OnUnembed(Id window_id) { 913 void WindowTreeClient::OnUnembed(Id window_id) {
905 WindowMus* window = GetWindowByServerId(window_id); 914 WindowMus* window = GetWindowByServerId(window_id);
(...skipping 22 matching lines...) Expand all
928 void WindowTreeClient::OnFrameSinkIdAllocated( 937 void WindowTreeClient::OnFrameSinkIdAllocated(
929 Id window_id, 938 Id window_id,
930 const cc::FrameSinkId& frame_sink_id) { 939 const cc::FrameSinkId& frame_sink_id) {
931 WindowMus* window = GetWindowByServerId(window_id); 940 WindowMus* window = GetWindowByServerId(window_id);
932 if (!window) 941 if (!window)
933 return; 942 return;
934 943
935 window->SetFrameSinkIdFromServer(frame_sink_id); 944 window->SetFrameSinkIdFromServer(frame_sink_id);
936 } 945 }
937 946
938 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, 947 void WindowTreeClient::OnTopLevelCreated(
939 ui::mojom::WindowDataPtr data, 948 uint32_t change_id,
940 int64_t display_id, 949 ui::mojom::WindowDataPtr data,
941 bool drawn, 950 int64_t display_id,
942 const cc::FrameSinkId& frame_sink_id) { 951 bool drawn,
952 const cc::FrameSinkId& frame_sink_id,
953 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
943 // The server ack'd the top level window we created and supplied the state 954 // The server ack'd the top level window we created and supplied the state
944 // of the window at the time the server created it. For properties we do not 955 // of the window at the time the server created it. For properties we do not
945 // have changes in flight for we can update them immediately. For properties 956 // have changes in flight for we can update them immediately. For properties
946 // with changes in flight we set the revert value from the server. 957 // with changes in flight we set the revert value from the server.
947 958
948 if (!in_flight_map_.count(change_id)) { 959 if (!in_flight_map_.count(change_id)) {
949 // The window may have been destroyed locally before the server could finish 960 // The window may have been destroyed locally before the server could finish
950 // creating the window, and before the server received the notification that 961 // creating the window, and before the server received the notification that
951 // the window has been destroyed. 962 // the window has been destroyed.
952 return; 963 return;
(...skipping 15 matching lines...) Expand all
968 InFlightChange* current_change = 979 InFlightChange* current_change =
969 GetOldestInFlightChangeMatching(visible_change); 980 GetOldestInFlightChangeMatching(visible_change);
970 if (current_change) 981 if (current_change)
971 current_change->SetRevertValueFrom(visible_change); 982 current_change->SetRevertValueFrom(visible_change);
972 else 983 else
973 SetWindowVisibleFromServer(window, true); 984 SetWindowVisibleFromServer(window, true);
974 } 985 }
975 986
976 const gfx::Rect bounds(data->bounds); 987 const gfx::Rect bounds(data->bounds);
977 { 988 {
978 // TODO(fsamuel): Propagate a cc::LocalSurfaceId through here. 989 InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id);
979 InFlightBoundsChange bounds_change(this, window, bounds, base::nullopt);
980 InFlightChange* current_change = 990 InFlightChange* current_change =
981 GetOldestInFlightChangeMatching(bounds_change); 991 GetOldestInFlightChangeMatching(bounds_change);
982 if (current_change) 992 if (current_change)
983 current_change->SetRevertValueFrom(bounds_change); 993 current_change->SetRevertValueFrom(bounds_change);
984 else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()), 994 else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()),
985 window->GetWindow()->bounds()) != bounds) 995 window->GetWindow()->bounds()) != bounds) {
986 SetWindowBoundsFromServer(window, bounds, base::nullopt); 996 SetWindowBoundsFromServer(window, bounds, local_surface_id);
997 }
987 } 998 }
988 999
989 // There is currently no API to bulk set properties, so we iterate over each 1000 // There is currently no API to bulk set properties, so we iterate over each
990 // property individually. 1001 // property individually.
991 for (const auto& pair : data->properties) { 1002 for (const auto& pair : data->properties) {
992 std::unique_ptr<std::vector<uint8_t>> revert_value( 1003 std::unique_ptr<std::vector<uint8_t>> revert_value(
993 base::MakeUnique<std::vector<uint8_t>>(pair.second)); 1004 base::MakeUnique<std::vector<uint8_t>>(pair.second));
994 InFlightPropertyChange property_change(window, pair.first, 1005 InFlightPropertyChange property_change(window, pair.first,
995 std::move(revert_value)); 1006 std::move(revert_value));
996 InFlightChange* current_change = 1007 InFlightChange* current_change =
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 // TODO(sky): having to block here is not ideal. http://crbug.com/594852. 1387 // TODO(sky): having to block here is not ideal. http://crbug.com/594852.
1377 while (!got_initial_displays_ && valid_wait) 1388 while (!got_initial_displays_ && valid_wait)
1378 valid_wait = binding_.WaitForIncomingMethodCall(); 1389 valid_wait = binding_.WaitForIncomingMethodCall();
1379 return valid_wait; 1390 return valid_wait;
1380 } 1391 }
1381 1392
1382 void WindowTreeClient::OnConnect(ClientSpecificId client_id) { 1393 void WindowTreeClient::OnConnect(ClientSpecificId client_id) {
1383 client_id_ = client_id; 1394 client_id_ = client_id;
1384 } 1395 }
1385 1396
1386 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, 1397 void WindowTreeClient::WmNewDisplayAdded(
1387 ui::mojom::WindowDataPtr root_data, 1398 const display::Display& display,
1388 bool parent_drawn, 1399 ui::mojom::WindowDataPtr root_data,
1389 const cc::FrameSinkId& frame_sink_id) { 1400 bool parent_drawn,
1401 const cc::FrameSinkId& frame_sink_id,
1402 const base::Optional<cc::LocalSurfaceId>& local_surface_id) {
1390 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn, 1403 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn,
1391 frame_sink_id); 1404 frame_sink_id, local_surface_id);
1392 } 1405 }
1393 1406
1394 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { 1407 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) {
1395 DCHECK(window_manager_delegate_); 1408 DCHECK(window_manager_delegate_);
1396 for (WindowMus* root : roots_) { 1409 for (WindowMus* root : roots_) {
1397 DCHECK(root->GetWindow()->GetHost()); 1410 DCHECK(root->GetWindow()->GetHost());
1398 WindowTreeHostMus* window_tree_host = 1411 WindowTreeHostMus* window_tree_host =
1399 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); 1412 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost());
1400 if (window_tree_host->display_id() == display_id) { 1413 if (window_tree_host->display_id() == display_id) {
1401 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); 1414 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host);
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1932 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1920 this, capture_synchronizer_.get(), window)); 1933 this, capture_synchronizer_.get(), window));
1921 } 1934 }
1922 1935
1923 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1936 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1924 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1937 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1925 this, focus_synchronizer_.get(), window)); 1938 this, focus_synchronizer_.get(), window));
1926 } 1939 }
1927 1940
1928 } // namespace aura 1941 } // 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