OLD | NEW |
---|---|
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 Loading... | |
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); |
459 DCHECK(frame_sink_id.is_valid()); | |
460 WindowMus::Get(window_tree_host->window()) | |
sky
2017/03/21 21:12:03
How come you call this here and not in WindowTreeH
Fady Samuel
2017/03/21 22:03:29
Oohh oops, I added this first then later decided t
| |
461 ->SetFrameSinkIdFromServer(frame_sink_id); | |
458 return window_tree_host; | 462 return window_tree_host; |
459 } | 463 } |
460 | 464 |
461 WindowMus* WindowTreeClient::NewWindowFromWindowData( | 465 WindowMus* WindowTreeClient::NewWindowFromWindowData( |
462 WindowMus* parent, | 466 WindowMus* parent, |
463 const ui::mojom::WindowData& window_data) { | 467 const ui::mojom::WindowData& window_data) { |
464 // This function is only called for windows coming from other clients. | 468 // This function is only called for windows coming from other clients. |
465 std::unique_ptr<WindowPortMus> window_port_mus( | 469 std::unique_ptr<WindowPortMus> window_port_mus( |
466 CreateWindowPortMus(window_data, WindowMusType::OTHER)); | 470 CreateWindowPortMus(window_data, WindowMusType::OTHER)); |
467 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); | 471 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 tree_->SetModalType(change_id, window->server_id(), | 531 tree_->SetModalType(change_id, window->server_id(), |
528 window->GetWindow()->GetProperty(client::kModalKey)); | 532 window->GetWindow()->GetProperty(client::kModalKey)); |
529 return true; | 533 return true; |
530 } | 534 } |
531 | 535 |
532 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree, | 536 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree, |
533 ClientSpecificId client_id, | 537 ClientSpecificId client_id, |
534 ui::mojom::WindowDataPtr root_data, | 538 ui::mojom::WindowDataPtr root_data, |
535 int64_t display_id, | 539 int64_t display_id, |
536 Id focused_window_id, | 540 Id focused_window_id, |
537 bool drawn) { | 541 bool drawn, |
542 const cc::FrameSinkId& frame_sink_id) { | |
538 // WARNING: this is only called if WindowTreeClient was created as the | 543 // WARNING: this is only called if WindowTreeClient was created as the |
539 // result of an embedding. | 544 // result of an embedding. |
540 client_id_ = client_id; | 545 client_id_ = client_id; |
541 WindowTreeConnectionEstablished(window_tree); | 546 WindowTreeConnectionEstablished(window_tree); |
542 | 547 |
543 DCHECK(roots_.empty()); | 548 DCHECK(roots_.empty()); |
544 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 549 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost( |
545 CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id); | 550 WindowMusType::EMBED, *root_data, display_id, frame_sink_id); |
546 | 551 |
547 focus_synchronizer_->SetFocusFromServer( | 552 focus_synchronizer_->SetFocusFromServer( |
548 GetWindowByServerId(focused_window_id)); | 553 GetWindowByServerId(focused_window_id)); |
549 | 554 |
550 delegate_->OnEmbed(std::move(window_tree_host)); | 555 delegate_->OnEmbed(std::move(window_tree_host)); |
551 } | 556 } |
552 | 557 |
553 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( | 558 WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl( |
554 const display::Display& display, | 559 const display::Display& display, |
555 ui::mojom::WindowDataPtr root_data, | 560 ui::mojom::WindowDataPtr root_data, |
556 bool parent_drawn) { | 561 bool parent_drawn, |
562 const cc::FrameSinkId& frame_sink_id) { | |
557 DCHECK(window_manager_delegate_); | 563 DCHECK(window_manager_delegate_); |
558 | 564 |
559 window_manager_delegate_->OnWmWillCreateDisplay(display); | 565 window_manager_delegate_->OnWmWillCreateDisplay(display); |
560 | 566 |
561 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 567 std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost( |
562 CreateWindowTreeHost(WindowMusType::DISPLAY, *root_data, display.id()); | 568 WindowMusType::DISPLAY, *root_data, display.id(), frame_sink_id); |
563 | 569 |
564 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get(); | 570 WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get(); |
565 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host), | 571 window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host), |
566 display); | 572 display); |
567 return window_tree_host_ptr; | 573 return window_tree_host_ptr; |
568 } | 574 } |
569 | 575 |
570 std::unique_ptr<EventResultCallback> | 576 std::unique_ptr<EventResultCallback> |
571 WindowTreeClient::CreateEventResultCallback(int32_t event_id) { | 577 WindowTreeClient::CreateEventResultCallback(int32_t event_id) { |
572 return base::MakeUnique<EventResultCallback>( | 578 return base::MakeUnique<EventResultCallback>( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 ui::mojom::EventTargetingPolicy policy) { | 876 ui::mojom::EventTargetingPolicy policy) { |
871 DCHECK(tree_); | 877 DCHECK(tree_); |
872 tree_->SetEventTargetingPolicy(window->server_id(), policy); | 878 tree_->SetEventTargetingPolicy(window->server_id(), policy); |
873 } | 879 } |
874 | 880 |
875 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, | 881 void WindowTreeClient::OnEmbed(ClientSpecificId client_id, |
876 ui::mojom::WindowDataPtr root_data, | 882 ui::mojom::WindowDataPtr root_data, |
877 ui::mojom::WindowTreePtr tree, | 883 ui::mojom::WindowTreePtr tree, |
878 int64_t display_id, | 884 int64_t display_id, |
879 Id focused_window_id, | 885 Id focused_window_id, |
880 bool drawn) { | 886 bool drawn, |
887 const cc::FrameSinkId& frame_sink_id) { | |
881 DCHECK(!tree_ptr_); | 888 DCHECK(!tree_ptr_); |
882 tree_ptr_ = std::move(tree); | 889 tree_ptr_ = std::move(tree); |
883 | 890 |
884 is_from_embed_ = true; | 891 is_from_embed_ = true; |
885 | 892 |
886 if (window_manager_delegate_) { | 893 if (window_manager_delegate_) { |
887 tree_ptr_->GetWindowManagerClient( | 894 tree_ptr_->GetWindowManagerClient( |
888 MakeRequest(&window_manager_internal_client_)); | 895 MakeRequest(&window_manager_internal_client_)); |
889 } | 896 } |
890 | 897 |
891 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, | 898 OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id, |
892 focused_window_id, drawn); | 899 focused_window_id, drawn, frame_sink_id); |
893 } | 900 } |
894 | 901 |
895 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) { | 902 void WindowTreeClient::OnEmbeddedAppDisconnected(Id window_id) { |
896 WindowMus* window = GetWindowByServerId(window_id); | 903 WindowMus* window = GetWindowByServerId(window_id); |
897 if (window) | 904 if (window) |
898 window->NotifyEmbeddedAppDisconnected(); | 905 window->NotifyEmbeddedAppDisconnected(); |
899 } | 906 } |
900 | 907 |
901 void WindowTreeClient::OnUnembed(Id window_id) { | 908 void WindowTreeClient::OnUnembed(Id window_id) { |
902 WindowMus* window = GetWindowByServerId(window_id); | 909 WindowMus* window = GetWindowByServerId(window_id); |
(...skipping 15 matching lines...) Expand all Loading... | |
918 new_capture_window); | 925 new_capture_window); |
919 if (ApplyServerChangeToExistingInFlightChange(change)) | 926 if (ApplyServerChangeToExistingInFlightChange(change)) |
920 return; | 927 return; |
921 | 928 |
922 capture_synchronizer_->SetCaptureFromServer(new_capture_window); | 929 capture_synchronizer_->SetCaptureFromServer(new_capture_window); |
923 } | 930 } |
924 | 931 |
925 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, | 932 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, |
926 ui::mojom::WindowDataPtr data, | 933 ui::mojom::WindowDataPtr data, |
927 int64_t display_id, | 934 int64_t display_id, |
928 bool drawn) { | 935 bool drawn, |
936 const cc::FrameSinkId& frame_sink_id) { | |
929 // The server ack'd the top level window we created and supplied the state | 937 // 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 | 938 // 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 | 939 // 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. | 940 // with changes in flight we set the revert value from the server. |
933 | 941 |
934 if (!in_flight_map_.count(change_id)) { | 942 if (!in_flight_map_.count(change_id)) { |
935 // The window may have been destroyed locally before the server could finish | 943 // The window may have been destroyed locally before the server could finish |
936 // creating the window, and before the server received the notification that | 944 // creating the window, and before the server received the notification that |
937 // the window has been destroyed. | 945 // the window has been destroyed. |
938 return; | 946 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 GetOldestInFlightChangeMatching(property_change); | 990 GetOldestInFlightChangeMatching(property_change); |
983 if (current_change) { | 991 if (current_change) { |
984 current_change->SetRevertValueFrom(property_change); | 992 current_change->SetRevertValueFrom(property_change); |
985 } else { | 993 } else { |
986 window->SetPropertyFromServer(pair.first, &pair.second); | 994 window->SetPropertyFromServer(pair.first, &pair.second); |
987 } | 995 } |
988 } | 996 } |
989 | 997 |
990 // Top level windows should not have a parent. | 998 // Top level windows should not have a parent. |
991 DCHECK_EQ(0u, data->parent_id); | 999 DCHECK_EQ(0u, data->parent_id); |
1000 | |
1001 window->SetFrameSinkIdFromServer(frame_sink_id); | |
992 } | 1002 } |
993 | 1003 |
994 void WindowTreeClient::OnWindowBoundsChanged( | 1004 void WindowTreeClient::OnWindowBoundsChanged( |
995 Id window_id, | 1005 Id window_id, |
996 const gfx::Rect& old_bounds, | 1006 const gfx::Rect& old_bounds, |
997 const gfx::Rect& new_bounds, | 1007 const gfx::Rect& new_bounds, |
998 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 1008 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
999 WindowMus* window = GetWindowByServerId(window_id); | 1009 WindowMus* window = GetWindowByServerId(window_id); |
1000 if (!window) | 1010 if (!window) |
1001 return; | 1011 return; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1350 // WindowTreeHost. | 1360 // WindowTreeHost. |
1351 GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest(); | 1361 GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest(); |
1352 } | 1362 } |
1353 | 1363 |
1354 void WindowTreeClient::OnConnect(ClientSpecificId client_id) { | 1364 void WindowTreeClient::OnConnect(ClientSpecificId client_id) { |
1355 client_id_ = client_id; | 1365 client_id_ = client_id; |
1356 } | 1366 } |
1357 | 1367 |
1358 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, | 1368 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, |
1359 ui::mojom::WindowDataPtr root_data, | 1369 ui::mojom::WindowDataPtr root_data, |
1360 bool parent_drawn) { | 1370 bool parent_drawn, |
1361 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn); | 1371 const cc::FrameSinkId& frame_sink_id) { |
1372 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn, | |
1373 frame_sink_id); | |
1362 } | 1374 } |
1363 | 1375 |
1364 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { | 1376 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { |
1365 DCHECK(window_manager_delegate_); | 1377 DCHECK(window_manager_delegate_); |
1366 for (WindowMus* root : roots_) { | 1378 for (WindowMus* root : roots_) { |
1367 DCHECK(root->GetWindow()->GetHost()); | 1379 DCHECK(root->GetWindow()->GetHost()); |
1368 WindowTreeHostMus* window_tree_host = | 1380 WindowTreeHostMus* window_tree_host = |
1369 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); | 1381 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); |
1370 if (window_tree_host->display_id() == display_id) { | 1382 if (window_tree_host->display_id() == display_id) { |
1371 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); | 1383 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1866 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1878 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1867 this, capture_synchronizer_.get(), window)); | 1879 this, capture_synchronizer_.get(), window)); |
1868 } | 1880 } |
1869 | 1881 |
1870 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1882 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1871 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1883 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1872 this, focus_synchronizer_.get(), window)); | 1884 this, focus_synchronizer_.get(), window)); |
1873 } | 1885 } |
1874 | 1886 |
1875 } // namespace aura | 1887 } // namespace aura |
OLD | NEW |