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

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

Issue 1759523002: mus: Server-side implementation of modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 4 years, 9 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (window && transient_window && !transient_window->Contains(window) && 216 if (window && transient_window && !transient_window->Contains(window) &&
217 access_policy_->CanAddTransientWindow(window, transient_window)) { 217 access_policy_->CanAddTransientWindow(window, transient_window)) {
218 Operation op(this, connection_manager_, 218 Operation op(this, connection_manager_,
219 OperationType::ADD_TRANSIENT_WINDOW); 219 OperationType::ADD_TRANSIENT_WINDOW);
220 window->AddTransientWindow(transient_window); 220 window->AddTransientWindow(transient_window);
221 return true; 221 return true;
222 } 222 }
223 return false; 223 return false;
224 } 224 }
225 225
226 bool WindowTree::SetAsModal(const ClientWindowId& window_id) {
227 ServerWindow* window = GetWindowByClientId(window_id);
228 if (window && access_policy_->CanSetAsModal(window)) {
229 window->SetAsModal();
230 Display* display = GetDisplay(window);
231 if (display)
232 display->ReleaseCaptureForModalWindow(window);
233 return true;
234 }
235 return false;
236 }
237
226 std::vector<const ServerWindow*> WindowTree::GetWindowTree( 238 std::vector<const ServerWindow*> WindowTree::GetWindowTree(
227 const ClientWindowId& window_id) const { 239 const ClientWindowId& window_id) const {
228 const ServerWindow* window = GetWindowByClientId(window_id); 240 const ServerWindow* window = GetWindowByClientId(window_id);
229 std::vector<const ServerWindow*> windows; 241 std::vector<const ServerWindow*> windows;
230 if (window) 242 if (window)
231 GetWindowTreeImpl(window, &windows); 243 GetWindowTreeImpl(window, &windows);
232 return windows; 244 return windows;
233 } 245 }
234 246
235 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, 247 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id,
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { 989 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) {
978 success = true; 990 success = true;
979 Operation op(this, connection_manager_, 991 Operation op(this, connection_manager_,
980 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); 992 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT);
981 transient_window->transient_parent()->RemoveTransientWindow( 993 transient_window->transient_parent()->RemoveTransientWindow(
982 transient_window); 994 transient_window);
983 } 995 }
984 client()->OnChangeCompleted(change_id, success); 996 client()->OnChangeCompleted(change_id, success);
985 } 997 }
986 998
999 void WindowTree::SetAsModal(uint32_t change_id, Id window_id) {
1000 client()->OnChangeCompleted(change_id, SetAsModal(ClientWindowId(window_id)));
1001 }
1002
987 void WindowTree::ReorderWindow(uint32_t change_id, 1003 void WindowTree::ReorderWindow(uint32_t change_id,
988 Id window_id, 1004 Id window_id,
989 Id relative_window_id, 1005 Id relative_window_id,
990 mojom::OrderDirection direction) { 1006 mojom::OrderDirection direction) {
991 bool success = false; 1007 bool success = false;
992 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1008 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
993 ServerWindow* relative_window = 1009 ServerWindow* relative_window =
994 GetWindowByClientId(ClientWindowId(relative_window_id)); 1010 GetWindowByClientId(ClientWindowId(relative_window_id));
995 if (CanReorderWindow(window, relative_window, direction)) { 1011 if (CanReorderWindow(window, relative_window, direction)) {
996 success = true; 1012 success = true;
(...skipping 17 matching lines...) Expand all
1014 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1030 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1015 Display* display = GetDisplay(window); 1031 Display* display = GetDisplay(window);
1016 ServerWindow* current_capture_window = 1032 ServerWindow* current_capture_window =
1017 display ? display->GetCaptureWindow() : nullptr; 1033 display ? display->GetCaptureWindow() : nullptr;
1018 bool success = window && access_policy_->CanSetCapture(window) && display && 1034 bool success = window && access_policy_->CanSetCapture(window) && display &&
1019 (!current_capture_window || 1035 (!current_capture_window ||
1020 access_policy_->CanSetCapture(current_capture_window)) && 1036 access_policy_->CanSetCapture(current_capture_window)) &&
1021 event_ack_id_; 1037 event_ack_id_;
1022 if (success) { 1038 if (success) {
1023 Operation op(this, connection_manager_, OperationType::SET_CAPTURE); 1039 Operation op(this, connection_manager_, OperationType::SET_CAPTURE);
1024 display->SetCapture(window, !HasRoot(window)); 1040 success = display->SetCapture(window, !HasRoot(window));
1025 } 1041 }
1026 client()->OnChangeCompleted(change_id, success); 1042 client()->OnChangeCompleted(change_id, success);
1027 } 1043 }
1028 1044
1029 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { 1045 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
1030 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1046 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1031 Display* display = GetDisplay(window); 1047 Display* display = GetDisplay(window);
1032 ServerWindow* current_capture_window = 1048 ServerWindow* current_capture_window =
1033 display ? display->GetCaptureWindow() : nullptr; 1049 display ? display->GetCaptureWindow() : nullptr;
1034 bool success = window && display && 1050 bool success = window && display &&
1035 (!current_capture_window || 1051 (!current_capture_window ||
1036 access_policy_->CanSetCapture(current_capture_window)) && 1052 access_policy_->CanSetCapture(current_capture_window)) &&
1037 window == current_capture_window; 1053 window == current_capture_window;
1038 if (success) { 1054 if (success) {
1039 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); 1055 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE);
1040 display->SetCapture(nullptr, false); 1056 success = display->SetCapture(nullptr, false);
1041 } 1057 }
1042 client()->OnChangeCompleted(change_id, success); 1058 client()->OnChangeCompleted(change_id, success);
1043 } 1059 }
1044 1060
1045 void WindowTree::SetWindowBounds(uint32_t change_id, 1061 void WindowTree::SetWindowBounds(uint32_t change_id,
1046 Id window_id, 1062 Id window_id,
1047 mojo::RectPtr bounds) { 1063 mojo::RectPtr bounds) {
1048 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1064 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1049 if (window && ShouldRouteToWindowManager(window)) { 1065 if (window && ShouldRouteToWindowManager(window)) {
1050 const uint32_t wm_change_id = 1066 const uint32_t wm_change_id =
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 1387
1372 for (const auto* root : roots_) { 1388 for (const auto* root : roots_) {
1373 if (root->Contains(window)) 1389 if (root->Contains(window))
1374 return true; 1390 return true;
1375 } 1391 }
1376 return false; 1392 return false;
1377 } 1393 }
1378 1394
1379 } // namespace ws 1395 } // namespace ws
1380 } // namespace mus 1396 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698