| 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 DCHECK(window_manager_internal_); | 666 DCHECK(window_manager_internal_); |
| 667 | 667 |
| 668 WindowManagerState* wms = display_manager() | 668 WindowManagerState* wms = display_manager() |
| 669 ->GetWindowManagerAndDisplay(*roots_.begin()) | 669 ->GetWindowManagerAndDisplay(*roots_.begin()) |
| 670 .window_manager_state; | 670 .window_manager_state; |
| 671 CHECK(wms); | 671 CHECK(wms); |
| 672 DCHECK_EQ(this, wms->tree()); | 672 DCHECK_EQ(this, wms->tree()); |
| 673 return wms; | 673 return wms; |
| 674 } | 674 } |
| 675 | 675 |
| 676 WindowManagerState* WindowTree::GetWindowManagerStateForUser() { |
| 677 Display* display = display_manager()->displays().empty() |
| 678 ? nullptr |
| 679 : *(display_manager()->displays().begin()); |
| 680 return display && user_id_ != InvalidUserId() |
| 681 ? display->GetWindowManagerStateForUser(user_id_) |
| 682 : nullptr; |
| 683 } |
| 684 |
| 676 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { | 685 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { |
| 677 // If the client created this window, then do not route it through the WM. | 686 // If the client created this window, then do not route it through the WM. |
| 678 if (window->id().connection_id == id_) | 687 if (window->id().connection_id == id_) |
| 679 return false; | 688 return false; |
| 680 | 689 |
| 681 // If the client did not create the window, then it must be the root of the | 690 // If the client did not create the window, then it must be the root of the |
| 682 // client. If not, that means the client should not know about this window, | 691 // client. If not, that means the client should not know about this window, |
| 683 // and so do not route the request to the WM. | 692 // and so do not route the request to the WM. |
| 684 if (roots_.count(window) == 0) | 693 if (roots_.count(window) == 0) |
| 685 return false; | 694 return false; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 client()->OnChangeCompleted( | 988 client()->OnChangeCompleted( |
| 980 change_id, NewWindow(ClientWindowId(transport_window_id), properties)); | 989 change_id, NewWindow(ClientWindowId(transport_window_id), properties)); |
| 981 } | 990 } |
| 982 | 991 |
| 983 void WindowTree::NewTopLevelWindow( | 992 void WindowTree::NewTopLevelWindow( |
| 984 uint32_t change_id, | 993 uint32_t change_id, |
| 985 Id transport_window_id, | 994 Id transport_window_id, |
| 986 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { | 995 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { |
| 987 DCHECK(!waiting_for_top_level_window_info_); | 996 DCHECK(!waiting_for_top_level_window_info_); |
| 988 const ClientWindowId client_window_id(transport_window_id); | 997 const ClientWindowId client_window_id(transport_window_id); |
| 989 // TODO(sky): need a way for client to provide context to figure out display. | |
| 990 Display* display = display_manager()->displays().empty() | |
| 991 ? nullptr | |
| 992 : *(display_manager()->displays().begin()); | |
| 993 // TODO(sky): move checks to accesspolicy. | 998 // TODO(sky): move checks to accesspolicy. |
| 994 WindowManagerState* wms = | 999 WindowManagerState* wms = GetWindowManagerStateForUser(); |
| 995 display && user_id_ != InvalidUserId() | |
| 996 ? display->GetWindowManagerStateForUser(user_id_) | |
| 997 : nullptr; | |
| 998 if (!wms || wms->tree() == this || !IsValidIdForNewWindow(client_window_id)) { | 1000 if (!wms || wms->tree() == this || !IsValidIdForNewWindow(client_window_id)) { |
| 999 client()->OnChangeCompleted(change_id, false); | 1001 client()->OnChangeCompleted(change_id, false); |
| 1000 return; | 1002 return; |
| 1001 } | 1003 } |
| 1002 | 1004 |
| 1003 // The server creates the real window. Any further messages from the client | 1005 // The server creates the real window. Any further messages from the client |
| 1004 // may try to alter the window. Pause incoming messages so that we know we | 1006 // may try to alter the window. Pause incoming messages so that we know we |
| 1005 // can't get a message for a window before the window is created. Once the | 1007 // can't get a message for a window before the window is created. Once the |
| 1006 // window is created we'll resume processing. | 1008 // window is created we'll resume processing. |
| 1007 binding_->SetIncomingMethodCallProcessingPaused(true); | 1009 binding_->SetIncomingMethodCallProcessingPaused(true); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) { | 1326 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) { |
| 1325 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ || | 1327 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ || |
| 1326 window_manager_internal_client_binding_) { | 1328 window_manager_internal_client_binding_) { |
| 1327 return; | 1329 return; |
| 1328 } | 1330 } |
| 1329 window_manager_internal_client_binding_.reset( | 1331 window_manager_internal_client_binding_.reset( |
| 1330 new mojo::AssociatedBinding<mojom::WindowManagerClient>( | 1332 new mojo::AssociatedBinding<mojom::WindowManagerClient>( |
| 1331 this, std::move(internal))); | 1333 this, std::move(internal))); |
| 1332 } | 1334 } |
| 1333 | 1335 |
| 1336 void WindowTree::GetCursorLocationMemory( |
| 1337 const GetCursorLocationMemoryCallback& callback) { |
| 1338 WindowManagerState* wms = GetWindowManagerStateForUser(); |
| 1339 callback.Run(wms->GetCursorLocationMemory()); |
| 1340 } |
| 1341 |
| 1334 void WindowTree::AddAccelerator(uint32_t id, | 1342 void WindowTree::AddAccelerator(uint32_t id, |
| 1335 mojom::EventMatcherPtr event_matcher, | 1343 mojom::EventMatcherPtr event_matcher, |
| 1336 const AddAcceleratorCallback& callback) { | 1344 const AddAcceleratorCallback& callback) { |
| 1337 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); | 1345 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); |
| 1338 const bool success = | 1346 const bool success = |
| 1339 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); | 1347 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); |
| 1340 callback.Run(success); | 1348 callback.Run(success); |
| 1341 } | 1349 } |
| 1342 | 1350 |
| 1343 void WindowTree::RemoveAccelerator(uint32_t id) { | 1351 void WindowTree::RemoveAccelerator(uint32_t id) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 } | 1439 } |
| 1432 | 1440 |
| 1433 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1441 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1434 const ServerWindow* window) const { | 1442 const ServerWindow* window) const { |
| 1435 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1443 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
| 1436 return tree && tree != this; | 1444 return tree && tree != this; |
| 1437 } | 1445 } |
| 1438 | 1446 |
| 1439 } // namespace ws | 1447 } // namespace ws |
| 1440 } // namespace mus | 1448 } // namespace mus |
| OLD | NEW |