| 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 if (!host || !host->GetWindowTree() || | 593 if (!host || !host->GetWindowTree() || |
| 594 !host->GetWindowTree()->window_manager_internal_) { | 594 !host->GetWindowTree()->window_manager_internal_) { |
| 595 return false; | 595 return false; |
| 596 } | 596 } |
| 597 | 597 |
| 598 // Requests coming from the WM should not be routed through the WM again. | 598 // Requests coming from the WM should not be routed through the WM again. |
| 599 const bool is_wm = host->GetWindowTree() == this; | 599 const bool is_wm = host->GetWindowTree() == this; |
| 600 return is_wm ? false : true; | 600 return is_wm ? false : true; |
| 601 } | 601 } |
| 602 | 602 |
| 603 void WindowTreeImpl::ProcessLostCapture(const ServerWindow* old_capture_window, |
| 604 bool originated_change) { |
| 605 if ((originated_change && |
| 606 connection_manager_->current_operation_type() == |
| 607 OperationType::RELEASE_CAPTURE) || |
| 608 !IsWindowKnown(old_capture_window)) { |
| 609 return; |
| 610 } |
| 611 client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id())); |
| 612 } |
| 613 |
| 603 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( | 614 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( |
| 604 const ServerWindow* window) const { | 615 const ServerWindow* window) const { |
| 605 auto iter = window_id_to_client_id_map_.find(window->id()); | 616 auto iter = window_id_to_client_id_map_.find(window->id()); |
| 606 DCHECK(iter != window_id_to_client_id_map_.end()); | 617 DCHECK(iter != window_id_to_client_id_map_.end()); |
| 607 return iter->second; | 618 return iter->second; |
| 608 } | 619 } |
| 609 | 620 |
| 610 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const { | 621 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const { |
| 611 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) { | 622 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) { |
| 612 // Embed roots see windows created from other connections. If they don't | 623 // 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... |
| 981 } | 992 } |
| 982 | 993 |
| 983 void WindowTreeImpl::GetWindowTree( | 994 void WindowTreeImpl::GetWindowTree( |
| 984 Id window_id, | 995 Id window_id, |
| 985 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { | 996 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { |
| 986 std::vector<const ServerWindow*> windows( | 997 std::vector<const ServerWindow*> windows( |
| 987 GetWindowTree(ClientWindowId(window_id))); | 998 GetWindowTree(ClientWindowId(window_id))); |
| 988 callback.Run(WindowsToWindowDatas(windows)); | 999 callback.Run(WindowsToWindowDatas(windows)); |
| 989 } | 1000 } |
| 990 | 1001 |
| 1002 void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) { |
| 1003 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1004 WindowTreeHostImpl* host = GetHost(window); |
| 1005 ServerWindow* current_capture_window = |
| 1006 host ? host->GetCaptureWindow() : nullptr; |
| 1007 bool success = window && access_policy_->CanSetCapture(window) && host && |
| 1008 (!current_capture_window || |
| 1009 access_policy_->CanSetCapture(current_capture_window)) && |
| 1010 event_ack_id_; |
| 1011 if (success) { |
| 1012 Operation op(this, connection_manager_, OperationType::SET_CAPTURE); |
| 1013 host->SetCapture(window, !HasRoot(window)); |
| 1014 } |
| 1015 client_->OnChangeCompleted(change_id, success); |
| 1016 } |
| 1017 |
| 1018 void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) { |
| 1019 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1020 WindowTreeHostImpl* host = GetHost(window); |
| 1021 ServerWindow* current_capture_window = |
| 1022 host ? host->GetCaptureWindow() : nullptr; |
| 1023 bool success = window && host && |
| 1024 (!current_capture_window || |
| 1025 access_policy_->CanSetCapture(current_capture_window)) && |
| 1026 window == current_capture_window; |
| 1027 if (success) { |
| 1028 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); |
| 1029 host->SetCapture(nullptr, false); |
| 1030 } |
| 1031 client_->OnChangeCompleted(change_id, success); |
| 1032 } |
| 1033 |
| 991 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, | 1034 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, |
| 992 Id window_id, | 1035 Id window_id, |
| 993 mojo::RectPtr bounds) { | 1036 mojo::RectPtr bounds) { |
| 994 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1037 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 995 if (window && ShouldRouteToWindowManager(window)) { | 1038 if (window && ShouldRouteToWindowManager(window)) { |
| 996 const uint32_t wm_change_id = | 1039 const uint32_t wm_change_id = |
| 997 connection_manager_->GenerateWindowManagerChangeId(this, change_id); | 1040 connection_manager_->GenerateWindowManagerChangeId(this, change_id); |
| 998 // |window_id| may be a client id, use the id from the window to ensure | 1041 // |window_id| may be a client id, use the id from the window to ensure |
| 999 // the windowmanager doesn't get an id it doesn't know about. | 1042 // the windowmanager doesn't get an id it doesn't know about. |
| 1000 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree(); | 1043 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree(); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1301 |
| 1259 for (const auto* root : roots_) { | 1302 for (const auto* root : roots_) { |
| 1260 if (root->Contains(window)) | 1303 if (root->Contains(window)) |
| 1261 return true; | 1304 return true; |
| 1262 } | 1305 } |
| 1263 return false; | 1306 return false; |
| 1264 } | 1307 } |
| 1265 | 1308 |
| 1266 } // namespace ws | 1309 } // namespace ws |
| 1267 } // namespace mus | 1310 } // namespace mus |
| OLD | NEW |