| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" |
| 16 #include "base/debug/stack_trace.h" |
| 15 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 16 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "cc/base/switches.h" |
| 17 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" | 20 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
| 18 #include "mojo/public/cpp/bindings/map.h" | 21 #include "mojo/public/cpp/bindings/map.h" |
| 19 #include "services/service_manager/public/cpp/connector.h" | 22 #include "services/service_manager/public/cpp/connector.h" |
| 20 #include "services/ui/common/accelerator_util.h" | 23 #include "services/ui/common/accelerator_util.h" |
| 21 #include "services/ui/public/cpp/gpu/gpu.h" | 24 #include "services/ui/public/cpp/gpu/gpu.h" |
| 22 #include "services/ui/public/cpp/property_type_converters.h" | 25 #include "services/ui/public/cpp/property_type_converters.h" |
| 23 #include "services/ui/public/interfaces/constants.mojom.h" | 26 #include "services/ui/public/interfaces/constants.mojom.h" |
| 24 #include "services/ui/public/interfaces/window_manager.mojom.h" | 27 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 25 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom
.h" | 28 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom
.h" |
| 26 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (create_discardable_memory) { | 219 if (create_discardable_memory) { |
| 217 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; | 220 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
| 218 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); | 221 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); |
| 219 discardable_shared_memory_manager_ = base::MakeUnique< | 222 discardable_shared_memory_manager_ = base::MakeUnique< |
| 220 discardable_memory::ClientDiscardableSharedMemoryManager>( | 223 discardable_memory::ClientDiscardableSharedMemoryManager>( |
| 221 std::move(manager_ptr), std::move(io_task_runner)); | 224 std::move(manager_ptr), std::move(io_task_runner)); |
| 222 base::DiscardableMemoryAllocator::SetInstance( | 225 base::DiscardableMemoryAllocator::SetInstance( |
| 223 discardable_shared_memory_manager_.get()); | 226 discardable_shared_memory_manager_.get()); |
| 224 } | 227 } |
| 225 } | 228 } |
| 229 enable_surface_synchronization_ = |
| 230 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 231 cc::switches::kEnableSurfaceSynchronization); |
| 226 } | 232 } |
| 227 | 233 |
| 228 WindowTreeClient::~WindowTreeClient() { | 234 WindowTreeClient::~WindowTreeClient() { |
| 229 in_destructor_ = true; | 235 in_destructor_ = true; |
| 230 | 236 |
| 231 if (discardable_shared_memory_manager_) | 237 if (discardable_shared_memory_manager_) |
| 232 base::DiscardableMemoryAllocator::SetInstance(nullptr); | 238 base::DiscardableMemoryAllocator::SetInstance(nullptr); |
| 233 | 239 |
| 234 for (WindowTreeClientObserver& observer : observers_) | 240 for (WindowTreeClientObserver& observer : observers_) |
| 235 observer.OnWillDestroyClient(this); | 241 observer.OnWillDestroyClient(this); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 453 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
| 448 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this, | 454 base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this, |
| 449 display_id, frame_sink_id); | 455 display_id, frame_sink_id); |
| 450 window_tree_host->InitHost(); | 456 window_tree_host->InitHost(); |
| 451 SetLocalPropertiesFromServerProperties( | 457 SetLocalPropertiesFromServerProperties( |
| 452 WindowMus::Get(window_tree_host->window()), window_data); | 458 WindowMus::Get(window_tree_host->window()), window_data); |
| 453 if (window_data.visible) { | 459 if (window_data.visible) { |
| 454 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()), | 460 SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()), |
| 455 true); | 461 true); |
| 456 } | 462 } |
| 457 SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()), | 463 WindowMus* window = WindowMus::Get(window_tree_host->window()); |
| 458 window_data.bounds); | 464 |
| 465 SetWindowBoundsFromServer(window, window_data.bounds, |
| 466 window_data.local_surface_id); |
| 459 return window_tree_host; | 467 return window_tree_host; |
| 460 } | 468 } |
| 461 | 469 |
| 462 WindowMus* WindowTreeClient::NewWindowFromWindowData( | 470 WindowMus* WindowTreeClient::NewWindowFromWindowData( |
| 463 WindowMus* parent, | 471 WindowMus* parent, |
| 464 const ui::mojom::WindowData& window_data) { | 472 const ui::mojom::WindowData& window_data) { |
| 465 // This function is only called for windows coming from other clients. | 473 // This function is only called for windows coming from other clients. |
| 466 std::unique_ptr<WindowPortMus> window_port_mus( | 474 std::unique_ptr<WindowPortMus> window_port_mus( |
| 467 CreateWindowPortMus(window_data, WindowMusType::OTHER)); | 475 CreateWindowPortMus(window_data, WindowMusType::OTHER)); |
| 468 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); | 476 WindowPortMus* window_port_mus_ptr = window_port_mus.get(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 } | 580 } |
| 573 | 581 |
| 574 void WindowTreeClient::OnReceivedCursorLocationMemory( | 582 void WindowTreeClient::OnReceivedCursorLocationMemory( |
| 575 mojo::ScopedSharedBufferHandle handle) { | 583 mojo::ScopedSharedBufferHandle handle) { |
| 576 cursor_location_mapping_ = handle->Map(sizeof(base::subtle::Atomic32)); | 584 cursor_location_mapping_ = handle->Map(sizeof(base::subtle::Atomic32)); |
| 577 DCHECK(cursor_location_mapping_); | 585 DCHECK(cursor_location_mapping_); |
| 578 } | 586 } |
| 579 | 587 |
| 580 void WindowTreeClient::SetWindowBoundsFromServer( | 588 void WindowTreeClient::SetWindowBoundsFromServer( |
| 581 WindowMus* window, | 589 WindowMus* window, |
| 582 const gfx::Rect& revert_bounds_in_pixels) { | 590 const gfx::Rect& revert_bounds_in_pixels, |
| 591 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 592 gfx::Rect bounds_in_pixels(revert_bounds_in_pixels); |
| 583 if (IsRoot(window)) { | 593 if (IsRoot(window)) { |
| 584 // WindowTreeHost expects bounds to be in pixels. | 594 // WindowTreeHost expects bounds to be in pixels. |
| 585 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); | 595 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); |
| 596 if (enable_surface_synchronization_ && local_surface_id && |
| 597 local_surface_id->is_valid()) { |
| 598 window->GetWindow()->GetHost()->compositor()->SetLocalSurfaceId( |
| 599 *local_surface_id); |
| 600 } |
| 586 return; | 601 return; |
| 587 } | 602 } |
| 588 | 603 |
| 589 window->SetBoundsFromServer(gfx::ConvertRectToDIP( | 604 window->SetBoundsFromServer(gfx::ConvertRectToDIP( |
| 590 ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels)); | 605 ScaleFactorForDisplay(window->GetWindow()), bounds_in_pixels)); |
| 591 } | 606 } |
| 592 | 607 |
| 593 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, | 608 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, |
| 594 bool visible) { | 609 bool visible) { |
| 595 if (!IsRoot(window)) { | 610 if (!IsRoot(window)) { |
| 596 window->SetVisibleFromServer(visible); | 611 window->SetVisibleFromServer(visible); |
| 597 return; | 612 return; |
| 598 } | 613 } |
| 599 | 614 |
| 600 std::unique_ptr<WindowMusChangeData> data = | 615 std::unique_ptr<WindowMusChangeData> data = |
| 601 window->PrepareForServerVisibilityChange(visible); | 616 window->PrepareForServerVisibilityChange(visible); |
| 602 WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window); | 617 WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window); |
| 603 if (visible) | 618 if (visible) |
| 604 window_tree_host->Show(); | 619 window_tree_host->Show(); |
| 605 else | 620 else |
| 606 window_tree_host->Hide(); | 621 window_tree_host->Hide(); |
| 607 } | 622 } |
| 608 | 623 |
| 609 void WindowTreeClient::ScheduleInFlightBoundsChange( | 624 void WindowTreeClient::ScheduleInFlightBoundsChange( |
| 610 WindowMus* window, | 625 WindowMus* window, |
| 611 const gfx::Rect& old_bounds, | 626 const gfx::Rect& old_bounds, |
| 612 const gfx::Rect& new_bounds) { | 627 const gfx::Rect& new_bounds) { |
| 613 const uint32_t change_id = ScheduleInFlightChange( | 628 const uint32_t change_id = |
| 614 base::MakeUnique<InFlightBoundsChange>(this, window, old_bounds)); | 629 ScheduleInFlightChange(base::MakeUnique<InFlightBoundsChange>( |
| 615 // TODO(fsamuel): Allocate a new LocalSurfaceId on size change. | 630 this, window, old_bounds, window->GetLocalSurfaceId())); |
| 631 base::Optional<cc::LocalSurfaceId> local_surface_id; |
| 632 if (enable_surface_synchronization_ && |
| 633 (window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| 634 window->window_mus_type() == WindowMusType::EMBED_IN_OWNER)) { |
| 635 local_surface_id = window->AllocateLocalSurfaceIdForSize(new_bounds.size()); |
| 636 } |
| 616 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds, | 637 tree_->SetWindowBounds(change_id, window->server_id(), new_bounds, |
| 617 base::nullopt); | 638 local_surface_id); |
| 618 } | 639 } |
| 619 | 640 |
| 620 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { | 641 void WindowTreeClient::OnWindowMusCreated(WindowMus* window) { |
| 621 if (window->server_id() != kInvalidServerId) | 642 if (window->server_id() != kInvalidServerId) |
| 622 return; | 643 return; |
| 623 | 644 |
| 624 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); | 645 window->set_server_id(MakeTransportId(client_id_, next_window_id_++)); |
| 625 RegisterWindowMus(window); | 646 RegisterWindowMus(window); |
| 626 | 647 |
| 627 DCHECK(window_manager_delegate_ || !IsRoot(window)); | 648 DCHECK(window_manager_delegate_ || !IsRoot(window)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } | 699 } |
| 679 for (auto change_id : in_flight_change_ids_to_remove) | 700 for (auto change_id : in_flight_change_ids_to_remove) |
| 680 in_flight_map_.erase(change_id); | 701 in_flight_map_.erase(change_id); |
| 681 | 702 |
| 682 roots_.erase(window); | 703 roots_.erase(window); |
| 683 } | 704 } |
| 684 | 705 |
| 685 void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window, | 706 void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window, |
| 686 const gfx::Rect& old_bounds, | 707 const gfx::Rect& old_bounds, |
| 687 const gfx::Rect& new_bounds) { | 708 const gfx::Rect& new_bounds) { |
| 709 // Called from window->SetBounds in aura. |
| 688 // Changes to bounds of root windows are routed through | 710 // Changes to bounds of root windows are routed through |
| 689 // OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side | 711 // OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side |
| 690 // effect of those and can be ignored. | 712 // effect of those and can be ignored. |
| 691 if (IsRoot(window)) | 713 if (IsRoot(window)) |
| 692 return; | 714 return; |
| 693 | 715 |
| 694 float device_scale_factor = ScaleFactorForDisplay(window->GetWindow()); | 716 float device_scale_factor = ScaleFactorForDisplay(window->GetWindow()); |
| 695 ScheduleInFlightBoundsChange( | 717 ScheduleInFlightBoundsChange( |
| 696 window, gfx::ConvertRectToPixel(device_scale_factor, old_bounds), | 718 window, gfx::ConvertRectToPixel(device_scale_factor, old_bounds), |
| 697 gfx::ConvertRectToPixel(device_scale_factor, new_bounds)); | 719 gfx::ConvertRectToPixel(device_scale_factor, new_bounds)); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, | 955 void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, |
| 934 ui::mojom::WindowDataPtr data, | 956 ui::mojom::WindowDataPtr data, |
| 935 int64_t display_id, | 957 int64_t display_id, |
| 936 bool drawn, | 958 bool drawn, |
| 937 const cc::FrameSinkId& frame_sink_id) { | 959 const cc::FrameSinkId& frame_sink_id) { |
| 938 // The server ack'd the top level window we created and supplied the state | 960 // The server ack'd the top level window we created and supplied the state |
| 939 // of the window at the time the server created it. For properties we do not | 961 // of the window at the time the server created it. For properties we do not |
| 940 // have changes in flight for we can update them immediately. For properties | 962 // have changes in flight for we can update them immediately. For properties |
| 941 // with changes in flight we set the revert value from the server. | 963 // with changes in flight we set the revert value from the server. |
| 942 | 964 |
| 965 const base::Optional<cc::LocalSurfaceId> local_surface_id( |
| 966 data->local_surface_id); |
| 943 if (!in_flight_map_.count(change_id)) { | 967 if (!in_flight_map_.count(change_id)) { |
| 944 // The window may have been destroyed locally before the server could finish | 968 // The window may have been destroyed locally before the server could finish |
| 945 // creating the window, and before the server received the notification that | 969 // creating the window, and before the server received the notification that |
| 946 // the window has been destroyed. | 970 // the window has been destroyed. |
| 947 return; | 971 return; |
| 948 } | 972 } |
| 949 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); | 973 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); |
| 950 in_flight_map_.erase(change_id); | 974 in_flight_map_.erase(change_id); |
| 951 | 975 |
| 952 WindowMus* window = change->window(); | 976 WindowMus* window = change->window(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 963 InFlightChange* current_change = | 987 InFlightChange* current_change = |
| 964 GetOldestInFlightChangeMatching(visible_change); | 988 GetOldestInFlightChangeMatching(visible_change); |
| 965 if (current_change) | 989 if (current_change) |
| 966 current_change->SetRevertValueFrom(visible_change); | 990 current_change->SetRevertValueFrom(visible_change); |
| 967 else | 991 else |
| 968 SetWindowVisibleFromServer(window, true); | 992 SetWindowVisibleFromServer(window, true); |
| 969 } | 993 } |
| 970 | 994 |
| 971 const gfx::Rect bounds(data->bounds); | 995 const gfx::Rect bounds(data->bounds); |
| 972 { | 996 { |
| 973 InFlightBoundsChange bounds_change(this, window, bounds); | 997 InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id); |
| 974 InFlightChange* current_change = | 998 InFlightChange* current_change = |
| 975 GetOldestInFlightChangeMatching(bounds_change); | 999 GetOldestInFlightChangeMatching(bounds_change); |
| 976 if (current_change) | 1000 if (current_change) |
| 977 current_change->SetRevertValueFrom(bounds_change); | 1001 current_change->SetRevertValueFrom(bounds_change); |
| 978 else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()), | 1002 else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()), |
| 979 window->GetWindow()->bounds()) != bounds) | 1003 window->GetWindow()->bounds()) != bounds) { |
| 980 SetWindowBoundsFromServer(window, bounds); | 1004 SetWindowBoundsFromServer(window, bounds, local_surface_id); |
| 1005 } |
| 981 } | 1006 } |
| 982 | 1007 |
| 983 // There is currently no API to bulk set properties, so we iterate over each | 1008 // There is currently no API to bulk set properties, so we iterate over each |
| 984 // property individually. | 1009 // property individually. |
| 985 for (const auto& pair : data->properties) { | 1010 for (const auto& pair : data->properties) { |
| 986 std::unique_ptr<std::vector<uint8_t>> revert_value( | 1011 std::unique_ptr<std::vector<uint8_t>> revert_value( |
| 987 base::MakeUnique<std::vector<uint8_t>>(pair.second)); | 1012 base::MakeUnique<std::vector<uint8_t>>(pair.second)); |
| 988 InFlightPropertyChange property_change(window, pair.first, | 1013 InFlightPropertyChange property_change(window, pair.first, |
| 989 std::move(revert_value)); | 1014 std::move(revert_value)); |
| 990 InFlightChange* current_change = | 1015 InFlightChange* current_change = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1004 | 1029 |
| 1005 void WindowTreeClient::OnWindowBoundsChanged( | 1030 void WindowTreeClient::OnWindowBoundsChanged( |
| 1006 Id window_id, | 1031 Id window_id, |
| 1007 const gfx::Rect& old_bounds, | 1032 const gfx::Rect& old_bounds, |
| 1008 const gfx::Rect& new_bounds, | 1033 const gfx::Rect& new_bounds, |
| 1009 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 1034 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 1010 WindowMus* window = GetWindowByServerId(window_id); | 1035 WindowMus* window = GetWindowByServerId(window_id); |
| 1011 if (!window) | 1036 if (!window) |
| 1012 return; | 1037 return; |
| 1013 | 1038 |
| 1014 InFlightBoundsChange new_change(this, window, new_bounds); | 1039 InFlightBoundsChange new_change(this, window, new_bounds, local_surface_id); |
| 1015 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 1040 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
| 1016 return; | 1041 return; |
| 1017 | 1042 |
| 1018 SetWindowBoundsFromServer(window, new_bounds); | 1043 SetWindowBoundsFromServer(window, new_bounds, local_surface_id); |
| 1019 } | 1044 } |
| 1020 | 1045 |
| 1021 void WindowTreeClient::OnClientAreaChanged( | 1046 void WindowTreeClient::OnClientAreaChanged( |
| 1022 uint32_t window_id, | 1047 uint32_t window_id, |
| 1023 const gfx::Insets& new_client_area, | 1048 const gfx::Insets& new_client_area, |
| 1024 const std::vector<gfx::Rect>& new_additional_client_areas) { | 1049 const std::vector<gfx::Rect>& new_additional_client_areas) { |
| 1025 WindowMus* window = GetWindowByServerId(window_id); | 1050 WindowMus* window = GetWindowByServerId(window_id); |
| 1026 if (!window) | 1051 if (!window) |
| 1027 return; | 1052 return; |
| 1028 | 1053 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 | 1285 |
| 1261 window->SetPredefinedCursorFromServer(cursor); | 1286 window->SetPredefinedCursorFromServer(cursor); |
| 1262 } | 1287 } |
| 1263 | 1288 |
| 1264 void WindowTreeClient::OnWindowSurfaceChanged( | 1289 void WindowTreeClient::OnWindowSurfaceChanged( |
| 1265 Id window_id, | 1290 Id window_id, |
| 1266 const cc::SurfaceInfo& surface_info) { | 1291 const cc::SurfaceInfo& surface_info) { |
| 1267 WindowMus* window = GetWindowByServerId(window_id); | 1292 WindowMus* window = GetWindowByServerId(window_id); |
| 1268 if (!window) | 1293 if (!window) |
| 1269 return; | 1294 return; |
| 1270 window->SetSurfaceInfoFromServer(surface_info); | 1295 if (enable_surface_synchronization_) |
| 1296 window->SetFallbackSurfaceInfo(surface_info); |
| 1297 else |
| 1298 window->SetPrimarySurfaceInfo(surface_info); |
| 1271 } | 1299 } |
| 1272 | 1300 |
| 1273 void WindowTreeClient::OnDragDropStart( | 1301 void WindowTreeClient::OnDragDropStart( |
| 1274 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) { | 1302 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) { |
| 1275 drag_drop_controller_->OnDragDropStart(mojo::UnorderedMapToMap(mime_data)); | 1303 drag_drop_controller_->OnDragDropStart(mojo::UnorderedMapToMap(mime_data)); |
| 1276 } | 1304 } |
| 1277 | 1305 |
| 1278 void WindowTreeClient::OnDragEnter(Id window_id, | 1306 void WindowTreeClient::OnDragEnter(Id window_id, |
| 1279 uint32_t key_state, | 1307 uint32_t key_state, |
| 1280 const gfx::Point& position, | 1308 const gfx::Point& position, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1294 } | 1322 } |
| 1295 | 1323 |
| 1296 void WindowTreeClient::OnDragLeave(Id window_id) { | 1324 void WindowTreeClient::OnDragLeave(Id window_id) { |
| 1297 drag_drop_controller_->OnDragLeave(GetWindowByServerId(window_id)); | 1325 drag_drop_controller_->OnDragLeave(GetWindowByServerId(window_id)); |
| 1298 } | 1326 } |
| 1299 | 1327 |
| 1300 void WindowTreeClient::OnDragDropDone() { | 1328 void WindowTreeClient::OnDragDropDone() { |
| 1301 drag_drop_controller_->OnDragDropDone(); | 1329 drag_drop_controller_->OnDragDropDone(); |
| 1302 } | 1330 } |
| 1303 | 1331 |
| 1332 void WindowTreeClient::OnSetWindowBoundsResponse( |
| 1333 uint32_t change_id, |
| 1334 const gfx::Rect& bounds, |
| 1335 const cc::LocalSurfaceId& local_surface_id) { |
| 1336 auto it = in_flight_map_.find(change_id); |
| 1337 DCHECK(it != in_flight_map_.end()); |
| 1338 // TODO(fsamuel): Fix this. |
| 1339 WindowMus* window = const_cast<WindowMus*>(it->second->window()); |
| 1340 DCHECK(window); |
| 1341 OnChangeCompleted(change_id, true); |
| 1342 InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id); |
| 1343 InFlightChange* current_change = |
| 1344 GetOldestInFlightChangeMatching(bounds_change); |
| 1345 if (current_change) |
| 1346 current_change->SetRevertValueFrom(bounds_change); |
| 1347 else |
| 1348 SetWindowBoundsFromServer(window, bounds, local_surface_id); |
| 1349 } |
| 1350 |
| 1304 void WindowTreeClient::OnCompleteDrop(Id window_id, | 1351 void WindowTreeClient::OnCompleteDrop(Id window_id, |
| 1305 uint32_t key_state, | 1352 uint32_t key_state, |
| 1306 const gfx::Point& position, | 1353 const gfx::Point& position, |
| 1307 uint32_t effect_bitmask, | 1354 uint32_t effect_bitmask, |
| 1308 const OnCompleteDropCallback& callback) { | 1355 const OnCompleteDropCallback& callback) { |
| 1309 callback.Run(drag_drop_controller_->OnCompleteDrop( | 1356 callback.Run(drag_drop_controller_->OnCompleteDrop( |
| 1310 GetWindowByServerId(window_id), key_state, position, effect_bitmask)); | 1357 GetWindowByServerId(window_id), key_state, position, effect_bitmask)); |
| 1311 } | 1358 } |
| 1312 | 1359 |
| 1313 void WindowTreeClient::OnPerformDragDropCompleted(uint32_t change_id, | 1360 void WindowTreeClient::OnPerformDragDropCompleted(uint32_t change_id, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 gfx::ConvertRectToDIP(device_scale_factor, transit_bounds_in_pixels); | 1452 gfx::ConvertRectToDIP(device_scale_factor, transit_bounds_in_pixels); |
| 1406 gfx::Rect bounds_in_dip = transit_bounds_in_dip; | 1453 gfx::Rect bounds_in_dip = transit_bounds_in_dip; |
| 1407 // TODO: this needs to trigger scheduling a bounds change on |window|. | 1454 // TODO: this needs to trigger scheduling a bounds change on |window|. |
| 1408 result = window_manager_delegate_->OnWmSetBounds(window->GetWindow(), | 1455 result = window_manager_delegate_->OnWmSetBounds(window->GetWindow(), |
| 1409 &bounds_in_dip); | 1456 &bounds_in_dip); |
| 1410 if (result) { | 1457 if (result) { |
| 1411 // If the resulting bounds differ return false. Returning false ensures | 1458 // If the resulting bounds differ return false. Returning false ensures |
| 1412 // the client applies the bounds we set below. | 1459 // the client applies the bounds we set below. |
| 1413 result = bounds_in_dip == transit_bounds_in_dip; | 1460 result = bounds_in_dip == transit_bounds_in_dip; |
| 1414 window->SetBoundsFromServer(bounds_in_dip); | 1461 window->SetBoundsFromServer(bounds_in_dip); |
| 1462 if (window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM && |
| 1463 window_manager_internal_client_) { |
| 1464 window_manager_internal_client_->WmSetBoundsResponse( |
| 1465 change_id, bounds_in_dip, window->GetLocalSurfaceId()); |
| 1466 return; |
| 1467 } |
| 1415 } | 1468 } |
| 1416 } else { | 1469 } else { |
| 1417 DVLOG(1) << "Unknown window passed to WmSetBounds()."; | 1470 DVLOG(1) << "Unknown window passed to WmSetBounds()."; |
| 1418 } | 1471 } |
| 1419 if (window_manager_internal_client_) | 1472 if (window_manager_internal_client_) |
| 1420 window_manager_internal_client_->WmResponse(change_id, result); | 1473 window_manager_internal_client_->WmResponse(change_id, result); |
| 1421 } | 1474 } |
| 1422 | 1475 |
| 1423 void WindowTreeClient::WmSetProperty( | 1476 void WindowTreeClient::WmSetProperty( |
| 1424 uint32_t change_id, | 1477 uint32_t change_id, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 if (properties) { | 1840 if (properties) { |
| 1788 for (const auto& property_pair : *properties) | 1841 for (const auto& property_pair : *properties) |
| 1789 transport_properties[property_pair.first] = property_pair.second; | 1842 transport_properties[property_pair.first] = property_pair.second; |
| 1790 } | 1843 } |
| 1791 | 1844 |
| 1792 const uint32_t change_id = | 1845 const uint32_t change_id = |
| 1793 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( | 1846 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( |
| 1794 window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW)); | 1847 window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW)); |
| 1795 tree_->NewTopLevelWindow(change_id, window_port->server_id(), | 1848 tree_->NewTopLevelWindow(change_id, window_port->server_id(), |
| 1796 transport_properties); | 1849 transport_properties); |
| 1850 |
| 1797 return window_port; | 1851 return window_port; |
| 1798 } | 1852 } |
| 1799 | 1853 |
| 1800 void WindowTreeClient::OnWindowTreeHostCreated( | 1854 void WindowTreeClient::OnWindowTreeHostCreated( |
| 1801 WindowTreeHostMus* window_tree_host) { | 1855 WindowTreeHostMus* window_tree_host) { |
| 1802 // All WindowTreeHosts are destroyed before this, so we don't need to unset | 1856 // All WindowTreeHosts are destroyed before this, so we don't need to unset |
| 1803 // the DragDropClient. | 1857 // the DragDropClient. |
| 1804 client::SetDragDropClient(window_tree_host->window(), | 1858 client::SetDragDropClient(window_tree_host->window(), |
| 1805 drag_drop_controller_.get()); | 1859 drag_drop_controller_.get()); |
| 1806 } | 1860 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1935 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1882 this, capture_synchronizer_.get(), window)); | 1936 this, capture_synchronizer_.get(), window)); |
| 1883 } | 1937 } |
| 1884 | 1938 |
| 1885 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1939 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1886 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1940 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1887 this, focus_synchronizer_.get(), window)); | 1941 this, focus_synchronizer_.get(), window)); |
| 1888 } | 1942 } |
| 1889 | 1943 |
| 1890 } // namespace aura | 1944 } // namespace aura |
| OLD | NEW |