| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void WindowTree::Init(scoped_ptr<WindowTreeBinding> binding, | 87 void WindowTree::Init(scoped_ptr<WindowTreeBinding> binding, |
| 88 mojom::WindowTreePtr tree) { | 88 mojom::WindowTreePtr tree) { |
| 89 DCHECK(!binding_); | 89 DCHECK(!binding_); |
| 90 binding_ = std::move(binding); | 90 binding_ = std::move(binding); |
| 91 | 91 |
| 92 if (roots_.empty()) | 92 if (roots_.empty()) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 std::vector<const ServerWindow*> to_send; | 95 std::vector<const ServerWindow*> to_send; |
| 96 CHECK_EQ(1u, roots_.size()); | 96 CHECK_EQ(1u, roots_.size()); |
| 97 GetUnknownWindowsFrom(*roots_.begin(), &to_send); | 97 const ServerWindow* root = *roots_.begin(); |
| 98 GetUnknownWindowsFrom(root, &to_send); |
| 98 | 99 |
| 99 Display* display = GetDisplay(*roots_.begin()); | 100 Display* display = GetDisplay(root); |
| 100 const ServerWindow* focused_window = | 101 const ServerWindow* focused_window = |
| 101 display ? display->GetFocusedWindow() : nullptr; | 102 display ? display->GetFocusedWindow() : nullptr; |
| 102 if (focused_window) | 103 if (focused_window) |
| 103 focused_window = access_policy_->GetWindowForFocusChange(focused_window); | 104 focused_window = access_policy_->GetWindowForFocusChange(focused_window); |
| 104 ClientWindowId focused_window_id; | 105 ClientWindowId focused_window_id; |
| 105 if (focused_window) | 106 if (focused_window) |
| 106 IsWindowKnown(focused_window, &focused_window_id); | 107 IsWindowKnown(focused_window, &focused_window_id); |
| 107 | 108 |
| 109 const bool drawn = root->parent() && root->parent()->IsDrawn(); |
| 108 client()->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), | 110 client()->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), |
| 109 focused_window_id.id); | 111 focused_window_id.id, drawn); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void WindowTree::ConfigureWindowManager() { | 114 void WindowTree::ConfigureWindowManager() { |
| 113 DCHECK(!window_manager_internal_); | 115 DCHECK(!window_manager_internal_); |
| 114 window_manager_internal_ = binding_->GetWindowManager(); | 116 window_manager_internal_ = binding_->GetWindowManager(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 const ServerWindow* WindowTree::GetWindow(const WindowId& id) const { | 119 const ServerWindow* WindowTree::GetWindow(const WindowId& id) const { |
| 118 if (id_ == id.connection_id) { | 120 if (id_ == id.connection_id) { |
| 119 auto iter = created_window_map_.find(id); | 121 auto iter = created_window_map_.find(id); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 std::move(waiting_for_top_level_window_info_)); | 334 std::move(waiting_for_top_level_window_info_)); |
| 333 binding_->SetIncomingMethodCallProcessingPaused(false); | 335 binding_->SetIncomingMethodCallProcessingPaused(false); |
| 334 // We were paused, so the id should still be valid. | 336 // We were paused, so the id should still be valid. |
| 335 DCHECK(IsValidIdForNewWindow( | 337 DCHECK(IsValidIdForNewWindow( |
| 336 waiting_for_top_level_window_info->client_window_id)); | 338 waiting_for_top_level_window_info->client_window_id)); |
| 337 client_id_to_window_id_map_[waiting_for_top_level_window_info | 339 client_id_to_window_id_map_[waiting_for_top_level_window_info |
| 338 ->client_window_id] = window->id(); | 340 ->client_window_id] = window->id(); |
| 339 window_id_to_client_id_map_[window->id()] = | 341 window_id_to_client_id_map_[window->id()] = |
| 340 waiting_for_top_level_window_info->client_window_id; | 342 waiting_for_top_level_window_info->client_window_id; |
| 341 roots_.insert(window); | 343 roots_.insert(window); |
| 342 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window)); | 344 const bool drawn = window->parent() && window->parent()->IsDrawn(); |
| 345 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), |
| 346 drawn); |
| 343 } | 347 } |
| 344 | 348 |
| 345 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { | 349 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { |
| 346 client()->OnChangeCompleted(change_id, success); | 350 client()->OnChangeCompleted(change_id, success); |
| 347 } | 351 } |
| 348 | 352 |
| 349 void WindowTree::OnAccelerator(uint32_t accelerator_id, | 353 void WindowTree::OnAccelerator(uint32_t accelerator_id, |
| 350 const ui::Event& event) { | 354 const ui::Event& event) { |
| 351 DCHECK(window_manager_internal_); | 355 DCHECK(window_manager_internal_); |
| 352 window_manager_internal_->OnAccelerator(accelerator_id, | 356 window_manager_internal_->OnAccelerator(accelerator_id, |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 parent = nullptr; | 812 parent = nullptr; |
| 809 mojom::WindowDataPtr window_data(mojom::WindowData::New()); | 813 mojom::WindowDataPtr window_data(mojom::WindowData::New()); |
| 810 window_data->parent_id = | 814 window_data->parent_id = |
| 811 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; | 815 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; |
| 812 window_data->window_id = | 816 window_data->window_id = |
| 813 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; | 817 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; |
| 814 window_data->bounds = Rect::From(window->bounds()); | 818 window_data->bounds = Rect::From(window->bounds()); |
| 815 window_data->properties = | 819 window_data->properties = |
| 816 mojo::Map<String, Array<uint8_t>>::From(window->properties()); | 820 mojo::Map<String, Array<uint8_t>>::From(window->properties()); |
| 817 window_data->visible = window->visible(); | 821 window_data->visible = window->visible(); |
| 818 window_data->drawn = window->IsDrawn(); | |
| 819 window_data->viewport_metrics = | 822 window_data->viewport_metrics = |
| 820 window_server_->GetViewportMetricsForWindow(window); | 823 window_server_->GetViewportMetricsForWindow(window); |
| 821 return window_data; | 824 return window_data; |
| 822 } | 825 } |
| 823 | 826 |
| 824 void WindowTree::GetWindowTreeImpl( | 827 void WindowTree::GetWindowTreeImpl( |
| 825 const ServerWindow* window, | 828 const ServerWindow* window, |
| 826 std::vector<const ServerWindow*>* windows) const { | 829 std::vector<const ServerWindow*>* windows) const { |
| 827 DCHECK(window); | 830 DCHECK(window); |
| 828 | 831 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 841 | 844 |
| 842 void WindowTree::NotifyDrawnStateChanged(const ServerWindow* window, | 845 void WindowTree::NotifyDrawnStateChanged(const ServerWindow* window, |
| 843 bool new_drawn_value) { | 846 bool new_drawn_value) { |
| 844 // Even though we don't know about window, it may be an ancestor of our root, | 847 // Even though we don't know about window, it may be an ancestor of our root, |
| 845 // in which case the change may effect our roots drawn state. | 848 // in which case the change may effect our roots drawn state. |
| 846 if (roots_.empty()) | 849 if (roots_.empty()) |
| 847 return; | 850 return; |
| 848 | 851 |
| 849 for (auto* root : roots_) { | 852 for (auto* root : roots_) { |
| 850 if (window->Contains(root) && (new_drawn_value != root->IsDrawn())) { | 853 if (window->Contains(root) && (new_drawn_value != root->IsDrawn())) { |
| 851 client()->OnWindowDrawnStateChanged(ClientWindowIdForWindow(root).id, | 854 client()->OnWindowParentDrawnStateChanged( |
| 852 new_drawn_value); | 855 ClientWindowIdForWindow(root).id, new_drawn_value); |
| 853 } | 856 } |
| 854 } | 857 } |
| 855 } | 858 } |
| 856 | 859 |
| 857 void WindowTree::DestroyWindows() { | 860 void WindowTree::DestroyWindows() { |
| 858 if (created_window_map_.empty()) | 861 if (created_window_map_.empty()) |
| 859 return; | 862 return; |
| 860 | 863 |
| 861 Operation op(this, window_server_, OperationType::DELETE_WINDOW); | 864 Operation op(this, window_server_, OperationType::DELETE_WINDOW); |
| 862 // If we get here from the destructor we're not going to get | 865 // If we get here from the destructor we're not going to get |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 } | 1371 } |
| 1369 | 1372 |
| 1370 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1373 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1371 const ServerWindow* window) const { | 1374 const ServerWindow* window) const { |
| 1372 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1375 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
| 1373 return tree && tree != this; | 1376 return tree && tree != this; |
| 1374 } | 1377 } |
| 1375 | 1378 |
| 1376 } // namespace ws | 1379 } // namespace ws |
| 1377 } // namespace mus | 1380 } // namespace mus |
| OLD | NEW |