| 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_impl.h" | 5 #include "components/mus/ws/window_tree_impl.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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (!host || !host->GetWindowTree() || | 600 if (!host || !host->GetWindowTree() || |
| 601 !host->GetWindowTree()->window_manager_internal_) { | 601 !host->GetWindowTree()->window_manager_internal_) { |
| 602 return false; | 602 return false; |
| 603 } | 603 } |
| 604 | 604 |
| 605 // Requests coming from the WM should not be routed through the WM again. | 605 // Requests coming from the WM should not be routed through the WM again. |
| 606 const bool is_wm = host->GetWindowTree() == this; | 606 const bool is_wm = host->GetWindowTree() == this; |
| 607 return is_wm ? false : true; | 607 return is_wm ? false : true; |
| 608 } | 608 } |
| 609 | 609 |
| 610 void WindowTreeImpl::ProcessLostCapture(const ServerWindow* old_capture_window, |
| 611 bool originated_change) { |
| 612 if ((originated_change && |
| 613 connection_manager_->current_operation_type() == |
| 614 OperationType::RELEASE_CAPTURE) || |
| 615 !IsWindowKnown(old_capture_window)) { |
| 616 return; |
| 617 } |
| 618 client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id())); |
| 619 } |
| 620 |
| 610 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( | 621 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( |
| 611 const ServerWindow* window) const { | 622 const ServerWindow* window) const { |
| 612 auto iter = window_id_to_client_id_map_.find(window->id()); | 623 auto iter = window_id_to_client_id_map_.find(window->id()); |
| 613 DCHECK(iter != window_id_to_client_id_map_.end()); | 624 DCHECK(iter != window_id_to_client_id_map_.end()); |
| 614 return iter->second; | 625 return iter->second; |
| 615 } | 626 } |
| 616 | 627 |
| 617 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const { | 628 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const { |
| 618 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) { | 629 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) { |
| 619 // Embed roots see windows created from other connections. If they don't | 630 // Embed roots see windows created from other connections. If they don't |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 999 } |
| 989 | 1000 |
| 990 void WindowTreeImpl::GetWindowTree( | 1001 void WindowTreeImpl::GetWindowTree( |
| 991 Id window_id, | 1002 Id window_id, |
| 992 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { | 1003 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { |
| 993 std::vector<const ServerWindow*> windows( | 1004 std::vector<const ServerWindow*> windows( |
| 994 GetWindowTree(ClientWindowId(window_id))); | 1005 GetWindowTree(ClientWindowId(window_id))); |
| 995 callback.Run(WindowsToWindowDatas(windows)); | 1006 callback.Run(WindowsToWindowDatas(windows)); |
| 996 } | 1007 } |
| 997 | 1008 |
| 1009 void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) { |
| 1010 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1011 WindowTreeHostImpl* host = GetHost(window); |
| 1012 ServerWindow* current_capture_window = |
| 1013 host ? host->GetCaptureWindow() : nullptr; |
| 1014 bool success = window && access_policy_->CanSetCapture(window) && host && |
| 1015 (!current_capture_window || |
| 1016 access_policy_->CanSetCapture(current_capture_window)) && |
| 1017 event_ack_id_; |
| 1018 if (success) { |
| 1019 Operation op(this, connection_manager_, OperationType::SET_CAPTURE); |
| 1020 host->SetCapture(window, !HasRoot(window)); |
| 1021 } |
| 1022 client_->OnChangeCompleted(change_id, success); |
| 1023 } |
| 1024 |
| 1025 void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) { |
| 1026 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1027 WindowTreeHostImpl* host = GetHost(window); |
| 1028 ServerWindow* current_capture_window = |
| 1029 host ? host->GetCaptureWindow() : nullptr; |
| 1030 bool success = window && host && |
| 1031 (!current_capture_window || |
| 1032 access_policy_->CanSetCapture(current_capture_window)) && |
| 1033 window == current_capture_window; |
| 1034 if (success) { |
| 1035 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); |
| 1036 host->SetCapture(nullptr, false); |
| 1037 } |
| 1038 client_->OnChangeCompleted(change_id, success); |
| 1039 } |
| 1040 |
| 998 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, | 1041 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, |
| 999 Id window_id, | 1042 Id window_id, |
| 1000 mojo::RectPtr bounds) { | 1043 mojo::RectPtr bounds) { |
| 1001 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1044 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1002 if (window && ShouldRouteToWindowManager(window)) { | 1045 if (window && ShouldRouteToWindowManager(window)) { |
| 1003 const uint32_t wm_change_id = | 1046 const uint32_t wm_change_id = |
| 1004 connection_manager_->GenerateWindowManagerChangeId(this, change_id); | 1047 connection_manager_->GenerateWindowManagerChangeId(this, change_id); |
| 1005 // |window_id| may be a client id, use the id from the window to ensure | 1048 // |window_id| may be a client id, use the id from the window to ensure |
| 1006 // the windowmanager doesn't get an id it doesn't know about. | 1049 // the windowmanager doesn't get an id it doesn't know about. |
| 1007 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree(); | 1050 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree(); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 | 1365 |
| 1323 for (const auto* root : roots_) { | 1366 for (const auto* root : roots_) { |
| 1324 if (root->Contains(window)) | 1367 if (root->Contains(window)) |
| 1325 return true; | 1368 return true; |
| 1326 } | 1369 } |
| 1327 return false; | 1370 return false; |
| 1328 } | 1371 } |
| 1329 | 1372 |
| 1330 } // namespace ws | 1373 } // namespace ws |
| 1331 } // namespace mus | 1374 } // namespace mus |
| OLD | NEW |