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 an a client embedded in | |
sadrul
2016/09/16 23:49:17
s/an//
sky
2016/09/18 15:40:07
Done.
| |
917 // it. | |
918 WindowTree* owning_tree = | |
919 window_server_->GetTreeWithId(window->id().client_id); | |
920 DCHECK(owning_tree && owning_tree != this); | |
921 owning_tree->client()->OnEmbeddedAppDisconnected( | |
922 owning_tree->ClientWindowIdForWindow(window).id); | |
923 } | |
913 } | 924 } |
914 | 925 |
915 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( | 926 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( |
916 const std::vector<const ServerWindow*>& windows) { | 927 const std::vector<const ServerWindow*>& windows) { |
917 Array<mojom::WindowDataPtr> array(windows.size()); | 928 Array<mojom::WindowDataPtr> array(windows.size()); |
918 for (size_t i = 0; i < windows.size(); ++i) | 929 for (size_t i = 0; i < windows.size(); ++i) |
919 array[i] = WindowToWindowData(windows[i]); | 930 array[i] = WindowToWindowData(windows[i]); |
920 return array; | 931 return array; |
921 } | 932 } |
922 | 933 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 display_root->window_manager_state() | 1117 display_root->window_manager_state() |
1107 ->window_tree() | 1118 ->window_tree() |
1108 ->window_manager_internal_->WmCreateTopLevelWindow( | 1119 ->window_manager_internal_->WmCreateTopLevelWindow( |
1109 wm_change_id, id_, std::move(transport_properties)); | 1120 wm_change_id, id_, std::move(transport_properties)); |
1110 } | 1121 } |
1111 | 1122 |
1112 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { | 1123 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { |
1113 ServerWindow* window = | 1124 ServerWindow* window = |
1114 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1125 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1115 bool success = false; | 1126 bool success = false; |
1116 bool should_close = window && (access_policy_->CanDeleteWindow(window) || | 1127 if (window && roots_.count(window) > 0) { |
1117 ShouldRouteToWindowManager(window)); | 1128 success = true; |
1118 if (should_close) { | 1129 window_server_->OnTreeMessagedClient(id_); |
1119 WindowTree* tree = | 1130 RemoveRoot(window, RemoveRootReason::UNEMBED); |
1120 window_server_->GetTreeWithId(window->id().client_id); | 1131 } else { |
1121 success = tree && tree->DeleteWindowImpl(this, window); | 1132 bool should_close = window && (access_policy_->CanDeleteWindow(window) || |
1133 ShouldRouteToWindowManager(window)); | |
1134 if (should_close) { | |
1135 WindowTree* tree = window_server_->GetTreeWithId(window->id().client_id); | |
1136 success = tree && tree->DeleteWindowImpl(this, window); | |
1137 } | |
1122 } | 1138 } |
1123 client()->OnChangeCompleted(change_id, success); | 1139 client()->OnChangeCompleted(change_id, success); |
1124 } | 1140 } |
1125 | 1141 |
1126 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { | 1142 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { |
1127 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), | 1143 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), |
1128 ClientWindowId(child_id))); | 1144 ClientWindowId(child_id))); |
1129 } | 1145 } |
1130 | 1146 |
1131 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { | 1147 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, | 1849 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
1834 effect_bitmask, callback); | 1850 effect_bitmask, callback); |
1835 } | 1851 } |
1836 | 1852 |
1837 void WindowTree::PerformOnDragDropDone() { | 1853 void WindowTree::PerformOnDragDropDone() { |
1838 client()->OnDragDropDone(); | 1854 client()->OnDragDropDone(); |
1839 } | 1855 } |
1840 | 1856 |
1841 } // namespace ws | 1857 } // namespace ws |
1842 } // namespace ui | 1858 } // namespace ui |
OLD | NEW |