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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 bool WindowTree::SetCapture(const ClientWindowId& client_window_id) { | 190 bool WindowTree::SetCapture(const ClientWindowId& client_window_id) { |
191 ServerWindow* window = GetWindowByClientId(client_window_id); | 191 ServerWindow* window = GetWindowByClientId(client_window_id); |
192 WindowManagerState* wms = GetWindowManagerState(window); | 192 WindowManagerState* wms = GetWindowManagerState(window); |
193 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; | 193 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; |
194 if (window && wms && wms->IsActive() && | 194 if (window && wms && wms->IsActive() && |
195 access_policy_->CanSetCapture(window) && | 195 access_policy_->CanSetCapture(window) && |
196 (!current_capture_window || | 196 (!current_capture_window || |
197 access_policy_->CanSetCapture(current_capture_window)) && | 197 access_policy_->CanSetCapture(current_capture_window)) && |
198 event_ack_id_) { | 198 event_ack_id_) { |
199 wms->SetCapture(window, !HasRoot(window)); | 199 return wms->SetCapture(window, !HasRoot(window)); |
200 return true; | |
201 } | 200 } |
202 return false; | 201 return false; |
203 } | 202 } |
204 | 203 |
205 bool WindowTree::NewWindow( | 204 bool WindowTree::NewWindow( |
206 const ClientWindowId& client_window_id, | 205 const ClientWindowId& client_window_id, |
207 const std::map<std::string, std::vector<uint8_t>>& properties) { | 206 const std::map<std::string, std::vector<uint8_t>>& properties) { |
208 if (!IsValidIdForNewWindow(client_window_id)) | 207 if (!IsValidIdForNewWindow(client_window_id)) |
209 return false; | 208 return false; |
210 const WindowId window_id = GenerateNewWindowId(); | 209 const WindowId window_id = GenerateNewWindowId(); |
(...skipping 26 matching lines...) Expand all Loading... |
237 if (window && transient_window && !transient_window->Contains(window) && | 236 if (window && transient_window && !transient_window->Contains(window) && |
238 access_policy_->CanAddTransientWindow(window, transient_window)) { | 237 access_policy_->CanAddTransientWindow(window, transient_window)) { |
239 Operation op(this, connection_manager_, | 238 Operation op(this, connection_manager_, |
240 OperationType::ADD_TRANSIENT_WINDOW); | 239 OperationType::ADD_TRANSIENT_WINDOW); |
241 window->AddTransientWindow(transient_window); | 240 window->AddTransientWindow(transient_window); |
242 return true; | 241 return true; |
243 } | 242 } |
244 return false; | 243 return false; |
245 } | 244 } |
246 | 245 |
| 246 bool WindowTree::SetModal(const ClientWindowId& window_id) { |
| 247 ServerWindow* window = GetWindowByClientId(window_id); |
| 248 if (window && access_policy_->CanSetModal(window)) { |
| 249 window->SetModal(); |
| 250 WindowManagerState* wms = GetWindowManagerState(window); |
| 251 if (wms) |
| 252 wms->ReleaseCaptureBlockedByModalWindow(window); |
| 253 return true; |
| 254 } |
| 255 return false; |
| 256 } |
| 257 |
247 std::vector<const ServerWindow*> WindowTree::GetWindowTree( | 258 std::vector<const ServerWindow*> WindowTree::GetWindowTree( |
248 const ClientWindowId& window_id) const { | 259 const ClientWindowId& window_id) const { |
249 const ServerWindow* window = GetWindowByClientId(window_id); | 260 const ServerWindow* window = GetWindowByClientId(window_id); |
250 std::vector<const ServerWindow*> windows; | 261 std::vector<const ServerWindow*> windows; |
251 if (window) | 262 if (window) |
252 GetWindowTreeImpl(window, &windows); | 263 GetWindowTreeImpl(window, &windows); |
253 return windows; | 264 return windows; |
254 } | 265 } |
255 | 266 |
256 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, | 267 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { | 1012 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { |
1002 success = true; | 1013 success = true; |
1003 Operation op(this, connection_manager_, | 1014 Operation op(this, connection_manager_, |
1004 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); | 1015 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); |
1005 transient_window->transient_parent()->RemoveTransientWindow( | 1016 transient_window->transient_parent()->RemoveTransientWindow( |
1006 transient_window); | 1017 transient_window); |
1007 } | 1018 } |
1008 client()->OnChangeCompleted(change_id, success); | 1019 client()->OnChangeCompleted(change_id, success); |
1009 } | 1020 } |
1010 | 1021 |
| 1022 void WindowTree::SetModal(uint32_t change_id, Id window_id) { |
| 1023 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id))); |
| 1024 } |
| 1025 |
1011 void WindowTree::ReorderWindow(uint32_t change_id, | 1026 void WindowTree::ReorderWindow(uint32_t change_id, |
1012 Id window_id, | 1027 Id window_id, |
1013 Id relative_window_id, | 1028 Id relative_window_id, |
1014 mojom::OrderDirection direction) { | 1029 mojom::OrderDirection direction) { |
1015 bool success = false; | 1030 bool success = false; |
1016 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1031 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
1017 ServerWindow* relative_window = | 1032 ServerWindow* relative_window = |
1018 GetWindowByClientId(ClientWindowId(relative_window_id)); | 1033 GetWindowByClientId(ClientWindowId(relative_window_id)); |
1019 if (CanReorderWindow(window, relative_window, direction)) { | 1034 if (CanReorderWindow(window, relative_window, direction)) { |
1020 success = true; | 1035 success = true; |
(...skipping 20 matching lines...) Expand all Loading... |
1041 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { | 1056 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { |
1042 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1057 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
1043 WindowManagerState* wms = GetWindowManagerState(window); | 1058 WindowManagerState* wms = GetWindowManagerState(window); |
1044 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; | 1059 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; |
1045 bool success = window && wms && wms->IsActive() && | 1060 bool success = window && wms && wms->IsActive() && |
1046 (!current_capture_window || | 1061 (!current_capture_window || |
1047 access_policy_->CanSetCapture(current_capture_window)) && | 1062 access_policy_->CanSetCapture(current_capture_window)) && |
1048 window == current_capture_window; | 1063 window == current_capture_window; |
1049 if (success) { | 1064 if (success) { |
1050 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); | 1065 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); |
1051 wms->SetCapture(nullptr, false); | 1066 success = wms->SetCapture(nullptr, false); |
1052 } | 1067 } |
1053 client()->OnChangeCompleted(change_id, success); | 1068 client()->OnChangeCompleted(change_id, success); |
1054 } | 1069 } |
1055 | 1070 |
1056 void WindowTree::SetWindowBounds(uint32_t change_id, | 1071 void WindowTree::SetWindowBounds(uint32_t change_id, |
1057 Id window_id, | 1072 Id window_id, |
1058 mojo::RectPtr bounds) { | 1073 mojo::RectPtr bounds) { |
1059 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1074 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
1060 if (window && ShouldRouteToWindowManager(window)) { | 1075 if (window && ShouldRouteToWindowManager(window)) { |
1061 const uint32_t wm_change_id = | 1076 const uint32_t wm_change_id = |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1394 |
1380 for (const auto* root : roots_) { | 1395 for (const auto* root : roots_) { |
1381 if (root->Contains(window)) | 1396 if (root->Contains(window)) |
1382 return true; | 1397 return true; |
1383 } | 1398 } |
1384 return false; | 1399 return false; |
1385 } | 1400 } |
1386 | 1401 |
1387 } // namespace ws | 1402 } // namespace ws |
1388 } // namespace mus | 1403 } // namespace mus |
OLD | NEW |