Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: components/mus/ws/window_tree.cc

Issue 1881253002: mus: Implement ScreenMus::GetCursorScreenPoint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows more. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 DCHECK(window_manager_internal_); 662 DCHECK(window_manager_internal_);
663 663
664 WindowManagerState* wms = display_manager() 664 WindowManagerState* wms = display_manager()
665 ->GetWindowManagerAndDisplay(*roots_.begin()) 665 ->GetWindowManagerAndDisplay(*roots_.begin())
666 .window_manager_state; 666 .window_manager_state;
667 CHECK(wms); 667 CHECK(wms);
668 DCHECK_EQ(this, wms->tree()); 668 DCHECK_EQ(this, wms->tree());
669 return wms; 669 return wms;
670 } 670 }
671 671
672 WindowManagerState* WindowTree::GetWindowManagerStateForUser() {
673 // TODO(sky): need a way for client to provide context to figure out display.
sky 2016/04/20 23:46:36 This TODO isn't applicable here.
674 Display* display = display_manager()->displays().empty()
675 ? nullptr
676 : *(display_manager()->displays().begin());
677 // TODO(sky): move checks to accesspolicy.
sky 2016/04/20 23:46:36 This TODO should be in NewTopLevelWindow, not here
678 return display && user_id_ != InvalidUserId()
679 ? display->GetWindowManagerStateForUser(user_id_)
680 : nullptr;
681 }
682
672 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { 683 bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const {
673 // If the client created this window, then do not route it through the WM. 684 // If the client created this window, then do not route it through the WM.
674 if (window->id().connection_id == id_) 685 if (window->id().connection_id == id_)
675 return false; 686 return false;
676 687
677 // If the client did not create the window, then it must be the root of the 688 // If the client did not create the window, then it must be the root of the
678 // client. If not, that means the client should not know about this window, 689 // client. If not, that means the client should not know about this window,
679 // and so do not route the request to the WM. 690 // and so do not route the request to the WM.
680 if (roots_.count(window) == 0) 691 if (roots_.count(window) == 0)
681 return false; 692 return false;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 client()->OnChangeCompleted( 979 client()->OnChangeCompleted(
969 change_id, NewWindow(ClientWindowId(transport_window_id), properties)); 980 change_id, NewWindow(ClientWindowId(transport_window_id), properties));
970 } 981 }
971 982
972 void WindowTree::NewTopLevelWindow( 983 void WindowTree::NewTopLevelWindow(
973 uint32_t change_id, 984 uint32_t change_id,
974 Id transport_window_id, 985 Id transport_window_id,
975 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 986 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
976 DCHECK(!waiting_for_top_level_window_info_); 987 DCHECK(!waiting_for_top_level_window_info_);
977 const ClientWindowId client_window_id(transport_window_id); 988 const ClientWindowId client_window_id(transport_window_id);
978 // TODO(sky): need a way for client to provide context to figure out display. 989 WindowManagerState* wms = GetWindowManagerStateForUser();
979 Display* display = display_manager()->displays().empty()
980 ? nullptr
981 : *(display_manager()->displays().begin());
982 // TODO(sky): move checks to accesspolicy.
983 WindowManagerState* wms =
984 display && user_id_ != InvalidUserId()
985 ? display->GetWindowManagerStateForUser(user_id_)
986 : nullptr;
987 if (!wms || wms->tree() == this || !IsValidIdForNewWindow(client_window_id)) { 990 if (!wms || wms->tree() == this || !IsValidIdForNewWindow(client_window_id)) {
988 client()->OnChangeCompleted(change_id, false); 991 client()->OnChangeCompleted(change_id, false);
989 return; 992 return;
990 } 993 }
991 994
992 // The server creates the real window. Any further messages from the client 995 // The server creates the real window. Any further messages from the client
993 // may try to alter the window. Pause incoming messages so that we know we 996 // may try to alter the window. Pause incoming messages so that we know we
994 // can't get a message for a window before the window is created. Once the 997 // can't get a message for a window before the window is created. Once the
995 // window is created we'll resume processing. 998 // window is created we'll resume processing.
996 binding_->SetIncomingMethodCallProcessingPaused(true); 999 binding_->SetIncomingMethodCallProcessingPaused(true);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) { 1305 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) {
1303 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ || 1306 if (!access_policy_->CanSetWindowManager() || !window_manager_internal_ ||
1304 window_manager_internal_client_binding_) { 1307 window_manager_internal_client_binding_) {
1305 return; 1308 return;
1306 } 1309 }
1307 window_manager_internal_client_binding_.reset( 1310 window_manager_internal_client_binding_.reset(
1308 new mojo::AssociatedBinding<mojom::WindowManagerClient>( 1311 new mojo::AssociatedBinding<mojom::WindowManagerClient>(
1309 this, std::move(internal))); 1312 this, std::move(internal)));
1310 } 1313 }
1311 1314
1315 void WindowTree::GetCursorLocationMemory(
1316 const GetCursorLocationMemoryCallback& callback) {
1317 WindowManagerState* wms = GetWindowManagerStateForUser();
1318 callback.Run(wms->GetCursorLocationMemory());
1319 }
1320
1312 void WindowTree::AddAccelerator(uint32_t id, 1321 void WindowTree::AddAccelerator(uint32_t id,
1313 mojom::EventMatcherPtr event_matcher, 1322 mojom::EventMatcherPtr event_matcher,
1314 const AddAcceleratorCallback& callback) { 1323 const AddAcceleratorCallback& callback) {
1315 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); 1324 WindowManagerState* wms = GetWindowManagerStateForWindowManager();
1316 const bool success = 1325 const bool success =
1317 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); 1326 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher));
1318 callback.Run(success); 1327 callback.Run(success);
1319 } 1328 }
1320 1329
1321 void WindowTree::RemoveAccelerator(uint32_t id) { 1330 void WindowTree::RemoveAccelerator(uint32_t id) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 } 1418 }
1410 1419
1411 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1420 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1412 const ServerWindow* window) const { 1421 const ServerWindow* window) const {
1413 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1422 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1414 return tree && tree != this; 1423 return tree && tree != this;
1415 } 1424 }
1416 1425
1417 } // namespace ws 1426 } // namespace ws
1418 } // namespace mus 1427 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698