| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 ServerWindow* window = GetWindowByClientId(window_id); | 287 ServerWindow* window = GetWindowByClientId(window_id); |
| 288 ServerWindow* transient_window = GetWindowByClientId(transient_window_id); | 288 ServerWindow* transient_window = GetWindowByClientId(transient_window_id); |
| 289 if (window && transient_window && !transient_window->Contains(window) && | 289 if (window && transient_window && !transient_window->Contains(window) && |
| 290 access_policy_->CanAddTransientWindow(window, transient_window)) { | 290 access_policy_->CanAddTransientWindow(window, transient_window)) { |
| 291 Operation op(this, window_server_, OperationType::ADD_TRANSIENT_WINDOW); | 291 Operation op(this, window_server_, OperationType::ADD_TRANSIENT_WINDOW); |
| 292 return window->AddTransientWindow(transient_window); | 292 return window->AddTransientWindow(transient_window); |
| 293 } | 293 } |
| 294 return false; | 294 return false; |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool WindowTree::DeleteWindow(const ClientWindowId& window_id) { |
| 298 ServerWindow* window = GetWindowByClientId(window_id); |
| 299 if (!window) |
| 300 return false; |
| 301 |
| 302 if (roots_.count(window) > 0) { |
| 303 // Deleting a root behaves as an unembed. |
| 304 window_server_->OnTreeMessagedClient(id_); |
| 305 RemoveRoot(window, RemoveRootReason::UNEMBED); |
| 306 return true; |
| 307 } |
| 308 |
| 309 if (!access_policy_->CanDeleteWindow(window) && |
| 310 !ShouldRouteToWindowManager(window)) { |
| 311 return false; |
| 312 } |
| 313 |
| 314 // Have the owner of the tree service the actual delete. |
| 315 WindowTree* tree = window_server_->GetTreeWithId(window->id().client_id); |
| 316 return tree && tree->DeleteWindowImpl(this, window); |
| 317 } |
| 318 |
| 297 bool WindowTree::SetModal(const ClientWindowId& window_id) { | 319 bool WindowTree::SetModal(const ClientWindowId& window_id) { |
| 298 ServerWindow* window = GetWindowByClientId(window_id); | 320 ServerWindow* window = GetWindowByClientId(window_id); |
| 299 if (window && access_policy_->CanSetModal(window)) { | 321 if (window && access_policy_->CanSetModal(window)) { |
| 300 WindowManagerDisplayRoot* display_root = | 322 WindowManagerDisplayRoot* display_root = |
| 301 GetWindowManagerDisplayRoot(window); | 323 GetWindowManagerDisplayRoot(window); |
| 302 if (window->transient_parent()) { | 324 if (window->transient_parent()) { |
| 303 window->SetModal(); | 325 window->SetModal(); |
| 304 } else if (user_id_ != InvalidUserId()) { | 326 } else if (user_id_ != InvalidUserId()) { |
| 305 if (display_root) | 327 if (display_root) |
| 306 display_root->window_manager_state()->AddSystemModalWindow(window); | 328 display_root->window_manager_state()->AddSystemModalWindow(window); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 if (needs_ack) | 487 if (needs_ack) |
| 466 GenerateEventAckId(); | 488 GenerateEventAckId(); |
| 467 else | 489 else |
| 468 DCHECK_EQ(0u, event_ack_id_); | 490 DCHECK_EQ(0u, event_ack_id_); |
| 469 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map | 491 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map |
| 470 // mojom::Event directly to ui::Event. | 492 // mojom::Event directly to ui::Event. |
| 471 window_manager_internal_->OnAccelerator(event_ack_id_, accelerator_id, | 493 window_manager_internal_->OnAccelerator(event_ack_id_, accelerator_id, |
| 472 ui::Event::Clone(event)); | 494 ui::Event::Clone(event)); |
| 473 } | 495 } |
| 474 | 496 |
| 497 void WindowTree::OnDisplayDestroying(int64_t display_id) { |
| 498 DCHECK(window_manager_internal_); |
| 499 window_manager_internal_->WmDisplayRemoved(display_id); |
| 500 } |
| 501 |
| 475 void WindowTree::ClientJankinessChanged(WindowTree* tree) { | 502 void WindowTree::ClientJankinessChanged(WindowTree* tree) { |
| 476 tree->janky_ = !tree->janky_; | 503 tree->janky_ = !tree->janky_; |
| 477 // Don't inform the client if it is the source of jank (which generally only | 504 // Don't inform the client if it is the source of jank (which generally only |
| 478 // happens while debugging). | 505 // happens while debugging). |
| 479 if (window_manager_internal_ && tree != this) { | 506 if (window_manager_internal_ && tree != this) { |
| 480 window_manager_internal_->WmClientJankinessChanged( | 507 window_manager_internal_->WmClientJankinessChanged( |
| 481 tree->id(), tree->janky()); | 508 tree->id(), tree->janky()); |
| 482 } | 509 } |
| 483 } | 510 } |
| 484 | 511 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 } | 931 } |
| 905 | 932 |
| 906 // This client no longer knows about the window. Unparent any windows that | 933 // This client no longer knows about the window. Unparent any windows that |
| 907 // were parented to windows in the root. | 934 // were parented to windows in the root. |
| 908 std::vector<ServerWindow*> local_windows; | 935 std::vector<ServerWindow*> local_windows; |
| 909 RemoveFromKnown(window, &local_windows); | 936 RemoveFromKnown(window, &local_windows); |
| 910 for (size_t i = 0; i < local_windows.size(); ++i) | 937 for (size_t i = 0; i < local_windows.size(); ++i) |
| 911 local_windows[i]->parent()->Remove(local_windows[i]); | 938 local_windows[i]->parent()->Remove(local_windows[i]); |
| 912 | 939 |
| 913 if (reason == RemoveRootReason::UNEMBED) { | 940 if (reason == RemoveRootReason::UNEMBED) { |
| 914 window->OnEmbeddedAppDisconnected(); | |
| 915 | |
| 916 // Notify the owner of the window it no longer has a client embedded in it. | 941 // Notify the owner of the window it no longer has a client embedded in it. |
| 942 // Owner is null in the case of the windowmanager unembedding itself from |
| 943 // a root. |
| 917 WindowTree* owning_tree = | 944 WindowTree* owning_tree = |
| 918 window_server_->GetTreeWithId(window->id().client_id); | 945 window_server_->GetTreeWithId(window->id().client_id); |
| 919 DCHECK(owning_tree && owning_tree != this); | 946 if (owning_tree) { |
| 920 owning_tree->client()->OnEmbeddedAppDisconnected( | 947 DCHECK(owning_tree && owning_tree != this); |
| 921 owning_tree->ClientWindowIdForWindow(window).id); | 948 owning_tree->client()->OnEmbeddedAppDisconnected( |
| 949 owning_tree->ClientWindowIdForWindow(window).id); |
| 950 } |
| 951 |
| 952 window->OnEmbeddedAppDisconnected(); |
| 922 } | 953 } |
| 923 } | 954 } |
| 924 | 955 |
| 925 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( | 956 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( |
| 926 const std::vector<const ServerWindow*>& windows) { | 957 const std::vector<const ServerWindow*>& windows) { |
| 927 Array<mojom::WindowDataPtr> array(windows.size()); | 958 Array<mojom::WindowDataPtr> array(windows.size()); |
| 928 for (size_t i = 0; i < windows.size(); ++i) | 959 for (size_t i = 0; i < windows.size(); ++i) |
| 929 array[i] = WindowToWindowData(windows[i]); | 960 array[i] = WindowToWindowData(windows[i]); |
| 930 return array; | 961 return array; |
| 931 } | 962 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 waiting_for_top_level_window_info_.reset( | 1144 waiting_for_top_level_window_info_.reset( |
| 1114 new WaitingForTopLevelWindowInfo(client_window_id, wm_change_id)); | 1145 new WaitingForTopLevelWindowInfo(client_window_id, wm_change_id)); |
| 1115 | 1146 |
| 1116 display_root->window_manager_state() | 1147 display_root->window_manager_state() |
| 1117 ->window_tree() | 1148 ->window_tree() |
| 1118 ->window_manager_internal_->WmCreateTopLevelWindow( | 1149 ->window_manager_internal_->WmCreateTopLevelWindow( |
| 1119 wm_change_id, id_, std::move(transport_properties)); | 1150 wm_change_id, id_, std::move(transport_properties)); |
| 1120 } | 1151 } |
| 1121 | 1152 |
| 1122 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { | 1153 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { |
| 1123 ServerWindow* window = | 1154 client()->OnChangeCompleted( |
| 1124 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1155 change_id, DeleteWindow(ClientWindowId(transport_window_id))); |
| 1125 bool success = false; | |
| 1126 if (window && roots_.count(window) > 0) { | |
| 1127 success = true; | |
| 1128 window_server_->OnTreeMessagedClient(id_); | |
| 1129 RemoveRoot(window, RemoveRootReason::UNEMBED); | |
| 1130 } else { | |
| 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 } | |
| 1137 } | |
| 1138 client()->OnChangeCompleted(change_id, success); | |
| 1139 } | 1156 } |
| 1140 | 1157 |
| 1141 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { | 1158 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { |
| 1142 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), | 1159 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), |
| 1143 ClientWindowId(child_id))); | 1160 ClientWindowId(child_id))); |
| 1144 } | 1161 } |
| 1145 | 1162 |
| 1146 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { | 1163 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { |
| 1147 bool success = false; | 1164 bool success = false; |
| 1148 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1165 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 1865 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 1849 effect_bitmask, callback); | 1866 effect_bitmask, callback); |
| 1850 } | 1867 } |
| 1851 | 1868 |
| 1852 void WindowTree::PerformOnDragDropDone() { | 1869 void WindowTree::PerformOnDragDropDone() { |
| 1853 client()->OnDragDropDone(); | 1870 client()->OnDragDropDone(); |
| 1854 } | 1871 } |
| 1855 | 1872 |
| 1856 } // namespace ws | 1873 } // namespace ws |
| 1857 } // namespace ui | 1874 } // namespace ui |
| OLD | NEW |