| 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 "components/mus/ws/window_tree.h" | 5 #include "components/mus/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 if (roots_.empty()) | 97 if (roots_.empty()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 std::vector<const ServerWindow*> to_send; | 100 std::vector<const ServerWindow*> to_send; |
| 101 CHECK_EQ(1u, roots_.size()); | 101 CHECK_EQ(1u, roots_.size()); |
| 102 const ServerWindow* root = *roots_.begin(); | 102 const ServerWindow* root = *roots_.begin(); |
| 103 GetUnknownWindowsFrom(root, &to_send); | 103 GetUnknownWindowsFrom(root, &to_send); |
| 104 | 104 |
| 105 Display* display = GetDisplay(root); | 105 Display* display = GetDisplay(root); |
| 106 int64_t display_id = |
| 107 display ? display->id() : display::Display::kInvalidDisplayID; |
| 106 const ServerWindow* focused_window = | 108 const ServerWindow* focused_window = |
| 107 display ? display->GetFocusedWindow() : nullptr; | 109 display ? display->GetFocusedWindow() : nullptr; |
| 108 if (focused_window) | 110 if (focused_window) |
| 109 focused_window = access_policy_->GetWindowForFocusChange(focused_window); | 111 focused_window = access_policy_->GetWindowForFocusChange(focused_window); |
| 110 ClientWindowId focused_window_id; | 112 ClientWindowId focused_window_id; |
| 111 if (focused_window) | 113 if (focused_window) |
| 112 IsWindowKnown(focused_window, &focused_window_id); | 114 IsWindowKnown(focused_window, &focused_window_id); |
| 113 | 115 |
| 114 const bool drawn = root->parent() && root->parent()->IsDrawn(); | 116 const bool drawn = root->parent() && root->parent()->IsDrawn(); |
| 115 client()->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), | 117 client()->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), |
| 116 focused_window_id.id, drawn); | 118 display_id, focused_window_id.id, drawn); |
| 117 } | 119 } |
| 118 | 120 |
| 119 void WindowTree::ConfigureWindowManager() { | 121 void WindowTree::ConfigureWindowManager() { |
| 120 DCHECK(!window_manager_internal_); | 122 DCHECK(!window_manager_internal_); |
| 121 window_manager_internal_ = binding_->GetWindowManager(); | 123 window_manager_internal_ = binding_->GetWindowManager(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 const ServerWindow* WindowTree::GetWindow(const WindowId& id) const { | 126 const ServerWindow* WindowTree::GetWindow(const WindowId& id) const { |
| 125 if (id_ == id.client_id) { | 127 if (id_ == id.client_id) { |
| 126 auto iter = created_window_map_.find(id); | 128 auto iter = created_window_map_.find(id); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 std::move(waiting_for_top_level_window_info_)); | 370 std::move(waiting_for_top_level_window_info_)); |
| 369 binding_->SetIncomingMethodCallProcessingPaused(false); | 371 binding_->SetIncomingMethodCallProcessingPaused(false); |
| 370 // We were paused, so the id should still be valid. | 372 // We were paused, so the id should still be valid. |
| 371 DCHECK(IsValidIdForNewWindow( | 373 DCHECK(IsValidIdForNewWindow( |
| 372 waiting_for_top_level_window_info->client_window_id)); | 374 waiting_for_top_level_window_info->client_window_id)); |
| 373 client_id_to_window_id_map_[waiting_for_top_level_window_info | 375 client_id_to_window_id_map_[waiting_for_top_level_window_info |
| 374 ->client_window_id] = window->id(); | 376 ->client_window_id] = window->id(); |
| 375 window_id_to_client_id_map_[window->id()] = | 377 window_id_to_client_id_map_[window->id()] = |
| 376 waiting_for_top_level_window_info->client_window_id; | 378 waiting_for_top_level_window_info->client_window_id; |
| 377 roots_.insert(window); | 379 roots_.insert(window); |
| 380 Display* display = GetDisplay(window); |
| 381 int64_t display_id = |
| 382 display ? display->id() : display::Display::kInvalidDisplayID; |
| 378 const bool drawn = window->parent() && window->parent()->IsDrawn(); | 383 const bool drawn = window->parent() && window->parent()->IsDrawn(); |
| 379 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), | 384 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), |
| 380 drawn); | 385 display_id, drawn); |
| 381 } | 386 } |
| 382 | 387 |
| 383 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { | 388 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { |
| 384 Display* host = GetDisplayForWindowManager(); | 389 Display* host = GetDisplayForWindowManager(); |
| 385 if (!host) | 390 if (!host) |
| 386 return; | 391 return; |
| 387 ServerWindow* window = GetWindowByClientId(window_id); | 392 ServerWindow* window = GetWindowByClientId(window_id); |
| 388 if (window) | 393 if (window) |
| 389 host->AddActivationParent(window); | 394 host->AddActivationParent(window); |
| 390 } | 395 } |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 Array<mojom::WindowDataPtr> array(windows.size()); | 849 Array<mojom::WindowDataPtr> array(windows.size()); |
| 845 for (size_t i = 0; i < windows.size(); ++i) | 850 for (size_t i = 0; i < windows.size(); ++i) |
| 846 array[i] = WindowToWindowData(windows[i]); | 851 array[i] = WindowToWindowData(windows[i]); |
| 847 return array; | 852 return array; |
| 848 } | 853 } |
| 849 | 854 |
| 850 mojom::WindowDataPtr WindowTree::WindowToWindowData( | 855 mojom::WindowDataPtr WindowTree::WindowToWindowData( |
| 851 const ServerWindow* window) { | 856 const ServerWindow* window) { |
| 852 DCHECK(IsWindowKnown(window)); | 857 DCHECK(IsWindowKnown(window)); |
| 853 const ServerWindow* parent = window->parent(); | 858 const ServerWindow* parent = window->parent(); |
| 854 | |
| 855 // Get the associated display before |parent| may be reset. | |
| 856 int64_t display_id = display::Display::kInvalidDisplayID; | |
| 857 const Display* display = display_manager()->GetDisplayContaining(window); | |
| 858 if (!display && parent) | |
| 859 display = display_manager()->GetDisplayContaining(parent); | |
| 860 if (display) | |
| 861 display_id = display->id(); | |
| 862 | |
| 863 // If the parent isn't known, it means the parent is not visible to us (not | 859 // If the parent isn't known, it means the parent is not visible to us (not |
| 864 // in roots), and should not be sent over. | 860 // in roots), and should not be sent over. |
| 865 if (parent && !IsWindowKnown(parent)) | 861 if (parent && !IsWindowKnown(parent)) |
| 866 parent = nullptr; | 862 parent = nullptr; |
| 867 mojom::WindowDataPtr window_data(mojom::WindowData::New()); | 863 mojom::WindowDataPtr window_data(mojom::WindowData::New()); |
| 868 window_data->parent_id = | 864 window_data->parent_id = |
| 869 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; | 865 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; |
| 870 window_data->window_id = | 866 window_data->window_id = |
| 871 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; | 867 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; |
| 872 window_data->bounds = Rect::From(window->bounds()); | 868 window_data->bounds = Rect::From(window->bounds()); |
| 873 window_data->properties = | 869 window_data->properties = |
| 874 mojo::Map<String, Array<uint8_t>>::From(window->properties()); | 870 mojo::Map<String, Array<uint8_t>>::From(window->properties()); |
| 875 window_data->visible = window->visible(); | 871 window_data->visible = window->visible(); |
| 876 window_data->display_id = display_id; | |
| 877 return window_data; | 872 return window_data; |
| 878 } | 873 } |
| 879 | 874 |
| 880 void WindowTree::GetWindowTreeImpl( | 875 void WindowTree::GetWindowTreeImpl( |
| 881 const ServerWindow* window, | 876 const ServerWindow* window, |
| 882 std::vector<const ServerWindow*>* windows) const { | 877 std::vector<const ServerWindow*>* windows) const { |
| 883 DCHECK(window); | 878 DCHECK(window); |
| 884 | 879 |
| 885 if (!access_policy_->CanGetWindowTree(window)) | 880 if (!access_policy_->CanGetWindowTree(window)) |
| 886 return; | 881 return; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 } | 1501 } |
| 1507 | 1502 |
| 1508 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1503 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1509 const ServerWindow* window) const { | 1504 const ServerWindow* window) const { |
| 1510 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1505 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
| 1511 return tree && tree != this; | 1506 return tree && tree != this; |
| 1512 } | 1507 } |
| 1513 | 1508 |
| 1514 } // namespace ws | 1509 } // namespace ws |
| 1515 } // namespace mus | 1510 } // namespace mus |
| OLD | NEW |