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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 window_manager_internal_->WmNewDisplayAdded(display->ToDisplay(), | 196 window_manager_internal_->WmNewDisplayAdded(display->ToDisplay(), |
197 WindowToWindowData(root), | 197 WindowToWindowData(root), |
198 root->parent()->IsDrawn()); | 198 root->parent()->IsDrawn()); |
199 } | 199 } |
200 | 200 |
201 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) { | 201 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) { |
202 if (event_source_wms_ && event_source_wms_->window_tree() == tree) | 202 if (event_source_wms_ && event_source_wms_->window_tree() == tree) |
203 event_source_wms_ = nullptr; | 203 event_source_wms_ = nullptr; |
204 | 204 |
205 // Notify our client if |tree| was embedded in any of our views. | 205 // Notify our client if |tree| was embedded in any of our windows. |
206 for (const auto* tree_root : tree->roots_) { | 206 for (const auto* tree_root : tree->roots_) { |
207 const bool owns_tree_root = tree_root->id().client_id == id_; | 207 const bool owns_tree_root = tree_root->id().client_id == id_; |
208 if (owns_tree_root) { | 208 if (owns_tree_root) { |
209 client()->OnEmbeddedAppDisconnected( | 209 client()->OnEmbeddedAppDisconnected( |
210 ClientWindowIdForWindow(tree_root).id); | 210 ClientWindowIdForWindow(tree_root).id); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 void WindowTree::NotifyChangeCompleted( | 215 void WindowTree::NotifyChangeCompleted( |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // doesn't know about the ancestors of the roots, and so can't do anything | 598 // doesn't know about the ancestors of the roots, and so can't do anything |
599 // about this ordering change of the root. | 599 // about this ordering change of the root. |
600 if (HasRoot(window) || HasRoot(relative_window)) | 600 if (HasRoot(window) || HasRoot(relative_window)) |
601 return; | 601 return; |
602 | 602 |
603 client()->OnWindowReordered(client_window_id.id, relative_client_window_id.id, | 603 client()->OnWindowReordered(client_window_id.id, relative_client_window_id.id, |
604 direction); | 604 direction); |
605 window_server_->OnTreeMessagedClient(id_); | 605 window_server_->OnTreeMessagedClient(id_); |
606 } | 606 } |
607 | 607 |
608 void WindowTree::ProcessWindowDeleted(const ServerWindow* window, | 608 void WindowTree::ProcessWindowDeleted(ServerWindow* window, |
609 bool originated_change) { | 609 bool originated_change) { |
610 if (window->id().client_id == id_) | 610 if (window->id().client_id == id_) |
611 created_window_map_.erase(window->id()); | 611 created_window_map_.erase(window->id()); |
612 | 612 |
613 ClientWindowId client_window_id; | 613 ClientWindowId client_window_id; |
614 if (!IsWindowKnown(window, &client_window_id)) | 614 if (!IsWindowKnown(window, &client_window_id)) |
615 return; | 615 return; |
616 | 616 |
617 if (HasRoot(window)) | 617 if (HasRoot(window)) |
618 RemoveRoot(window, RemoveRootReason::DELETED); | 618 RemoveRoot(window, RemoveRootReason::DELETED); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 return; | 880 return; |
881 } | 881 } |
882 | 882 |
883 RemoveFromMaps(window); | 883 RemoveFromMaps(window); |
884 | 884 |
885 const ServerWindow::Windows& children = window->children(); | 885 const ServerWindow::Windows& children = window->children(); |
886 for (ServerWindow* child : children) | 886 for (ServerWindow* child : children) |
887 RemoveFromKnown(child, local_windows); | 887 RemoveFromKnown(child, local_windows); |
888 } | 888 } |
889 | 889 |
890 void WindowTree::RemoveRoot(const ServerWindow* window, | 890 void WindowTree::RemoveRoot(ServerWindow* window, RemoveRootReason reason) { |
891 RemoveRootReason reason) { | |
892 DCHECK(roots_.count(window) > 0); | 891 DCHECK(roots_.count(window) > 0); |
893 roots_.erase(window); | 892 roots_.erase(window); |
894 | 893 |
895 const ClientWindowId client_window_id(ClientWindowIdForWindow(window)); | 894 const ClientWindowId client_window_id(ClientWindowIdForWindow(window)); |
896 | 895 |
897 // No need to do anything if we created the window. | 896 // No need to do anything if we created the window. |
898 if (window->id().client_id == id_) | 897 if (window->id().client_id == id_) |
899 return; | 898 return; |
900 | 899 |
901 if (reason == RemoveRootReason::EMBED) { | 900 if (reason == RemoveRootReason::EMBED) { |
902 client()->OnUnembed(client_window_id.id); | 901 client()->OnUnembed(client_window_id.id); |
903 client()->OnWindowDeleted(client_window_id.id); | 902 client()->OnWindowDeleted(client_window_id.id); |
904 window_server_->OnTreeMessagedClient(id_); | 903 window_server_->OnTreeMessagedClient(id_); |
905 } | 904 } |
906 | 905 |
907 // This client no longer knows about the window. Unparent any windows that | 906 // This client no longer knows about the window. Unparent any windows that |
908 // were parented to windows in the root. | 907 // were parented to windows in the root. |
909 std::vector<ServerWindow*> local_windows; | 908 std::vector<ServerWindow*> local_windows; |
910 RemoveFromKnown(window, &local_windows); | 909 RemoveFromKnown(window, &local_windows); |
911 for (size_t i = 0; i < local_windows.size(); ++i) | 910 for (size_t i = 0; i < local_windows.size(); ++i) |
912 local_windows[i]->parent()->Remove(local_windows[i]); | 911 local_windows[i]->parent()->Remove(local_windows[i]); |
| 912 |
| 913 if (reason == RemoveRootReason::UNEMBED) { |
| 914 window->OnEmbeddedAppDisconnected(); |
| 915 |
| 916 // Notify the owner of the window it no longer has a client embedded in it. |
| 917 WindowTree* owning_tree = |
| 918 window_server_->GetTreeWithId(window->id().client_id); |
| 919 DCHECK(owning_tree && owning_tree != this); |
| 920 owning_tree->client()->OnEmbeddedAppDisconnected( |
| 921 owning_tree->ClientWindowIdForWindow(window).id); |
| 922 } |
913 } | 923 } |
914 | 924 |
915 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( | 925 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( |
916 const std::vector<const ServerWindow*>& windows) { | 926 const std::vector<const ServerWindow*>& windows) { |
917 Array<mojom::WindowDataPtr> array(windows.size()); | 927 Array<mojom::WindowDataPtr> array(windows.size()); |
918 for (size_t i = 0; i < windows.size(); ++i) | 928 for (size_t i = 0; i < windows.size(); ++i) |
919 array[i] = WindowToWindowData(windows[i]); | 929 array[i] = WindowToWindowData(windows[i]); |
920 return array; | 930 return array; |
921 } | 931 } |
922 | 932 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 display_root->window_manager_state() | 1116 display_root->window_manager_state() |
1107 ->window_tree() | 1117 ->window_tree() |
1108 ->window_manager_internal_->WmCreateTopLevelWindow( | 1118 ->window_manager_internal_->WmCreateTopLevelWindow( |
1109 wm_change_id, id_, std::move(transport_properties)); | 1119 wm_change_id, id_, std::move(transport_properties)); |
1110 } | 1120 } |
1111 | 1121 |
1112 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { | 1122 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { |
1113 ServerWindow* window = | 1123 ServerWindow* window = |
1114 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1124 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1115 bool success = false; | 1125 bool success = false; |
1116 bool should_close = window && (access_policy_->CanDeleteWindow(window) || | 1126 if (window && roots_.count(window) > 0) { |
1117 ShouldRouteToWindowManager(window)); | 1127 success = true; |
1118 if (should_close) { | 1128 window_server_->OnTreeMessagedClient(id_); |
1119 WindowTree* tree = | 1129 RemoveRoot(window, RemoveRootReason::UNEMBED); |
1120 window_server_->GetTreeWithId(window->id().client_id); | 1130 } else { |
1121 success = tree && tree->DeleteWindowImpl(this, window); | 1131 bool should_close = window && (access_policy_->CanDeleteWindow(window) || |
| 1132 ShouldRouteToWindowManager(window)); |
| 1133 if (should_close) { |
| 1134 WindowTree* tree = window_server_->GetTreeWithId(window->id().client_id); |
| 1135 success = tree && tree->DeleteWindowImpl(this, window); |
| 1136 } |
1122 } | 1137 } |
1123 client()->OnChangeCompleted(change_id, success); | 1138 client()->OnChangeCompleted(change_id, success); |
1124 } | 1139 } |
1125 | 1140 |
1126 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { | 1141 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { |
1127 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), | 1142 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), |
1128 ClientWindowId(child_id))); | 1143 ClientWindowId(child_id))); |
1129 } | 1144 } |
1130 | 1145 |
1131 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { | 1146 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 1848 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
1834 effect_bitmask, callback); | 1849 effect_bitmask, callback); |
1835 } | 1850 } |
1836 | 1851 |
1837 void WindowTree::PerformOnDragDropDone() { | 1852 void WindowTree::PerformOnDragDropDone() { |
1838 client()->OnDragDropDone(); | 1853 client()->OnDragDropDone(); |
1839 } | 1854 } |
1840 | 1855 |
1841 } // namespace ws | 1856 } // namespace ws |
1842 } // namespace ui | 1857 } // namespace ui |
OLD | NEW |