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

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2710023007: Make WindowTree::SetModal() take the type. (Closed)
Patch Set: address feedback. Created 3 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
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/ws/window_tree.h" 5 #include "services/ui/ws/window_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (!access_policy_->CanDeleteWindow(window) && 345 if (!access_policy_->CanDeleteWindow(window) &&
346 !ShouldRouteToWindowManager(window)) { 346 !ShouldRouteToWindowManager(window)) {
347 return false; 347 return false;
348 } 348 }
349 349
350 // Have the owner of the tree service the actual delete. 350 // Have the owner of the tree service the actual delete.
351 WindowTree* tree = window_server_->GetTreeWithId(window->id().client_id); 351 WindowTree* tree = window_server_->GetTreeWithId(window->id().client_id);
352 return tree && tree->DeleteWindowImpl(this, window); 352 return tree && tree->DeleteWindowImpl(this, window);
353 } 353 }
354 354
355 bool WindowTree::SetModal(const ClientWindowId& window_id) { 355 bool WindowTree::SetModalType(const ClientWindowId& window_id,
356 ModalType modal_type) {
356 ServerWindow* window = GetWindowByClientId(window_id); 357 ServerWindow* window = GetWindowByClientId(window_id);
357 if (window && access_policy_->CanSetModal(window)) { 358 if (!window || !access_policy_->CanSetModal(window))
358 WindowManagerDisplayRoot* display_root = 359 return false;
359 GetWindowManagerDisplayRoot(window); 360
360 if (window->transient_parent()) { 361 if (window->modal_type() == modal_type)
361 window->SetModal();
362 } else if (user_id_ != InvalidUserId()) {
363 if (display_root)
364 display_root->window_manager_state()->AddSystemModalWindow(window);
365 } else {
366 return false;
367 }
368 if (display_root)
369 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow(
370 window);
371 return true; 362 return true;
363
364 // TODO(moshayedi): crbug.com/697176. When modality of a window that used to
365 // be a system modal changes, notify window manager state.
366 auto* display_root = GetWindowManagerDisplayRoot(window);
367 switch (modal_type) {
368 case MODAL_TYPE_SYSTEM:
369 if (user_id_ == InvalidUserId() || !display_root)
370 return false;
371 window->SetModalType(modal_type);
372 display_root->window_manager_state()->AddSystemModalWindow(window);
373 break;
374 case MODAL_TYPE_NONE:
375 case MODAL_TYPE_WINDOW:
376 case MODAL_TYPE_CHILD:
377 window->SetModalType(modal_type);
378 break;
372 } 379 }
373 return false; 380 if (display_root && modal_type != MODAL_TYPE_NONE) {
381 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow(
382 window);
383 }
384 return true;
374 } 385 }
375 386
376 std::vector<const ServerWindow*> WindowTree::GetWindowTree( 387 std::vector<const ServerWindow*> WindowTree::GetWindowTree(
377 const ClientWindowId& window_id) const { 388 const ClientWindowId& window_id) const {
378 const ServerWindow* window = GetWindowByClientId(window_id); 389 const ServerWindow* window = GetWindowByClientId(window_id);
379 std::vector<const ServerWindow*> windows; 390 std::vector<const ServerWindow*> windows;
380 if (window) 391 if (window)
381 GetWindowTreeImpl(window, &windows); 392 GetWindowTreeImpl(window, &windows);
382 return windows; 393 return windows;
383 } 394 }
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { 1282 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) {
1272 success = true; 1283 success = true;
1273 Operation op(this, window_server_, 1284 Operation op(this, window_server_,
1274 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); 1285 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT);
1275 transient_window->transient_parent()->RemoveTransientWindow( 1286 transient_window->transient_parent()->RemoveTransientWindow(
1276 transient_window); 1287 transient_window);
1277 } 1288 }
1278 client()->OnChangeCompleted(change_id, success); 1289 client()->OnChangeCompleted(change_id, success);
1279 } 1290 }
1280 1291
1281 void WindowTree::SetModal(uint32_t change_id, Id window_id) { 1292 void WindowTree::SetModalType(uint32_t change_id,
1282 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id))); 1293 Id window_id,
1294 ModalType modal_type) {
1295 client()->OnChangeCompleted(
1296 change_id, SetModalType(ClientWindowId(window_id), modal_type));
1283 } 1297 }
1284 1298
1285 void WindowTree::ReorderWindow(uint32_t change_id, 1299 void WindowTree::ReorderWindow(uint32_t change_id,
1286 Id window_id, 1300 Id window_id,
1287 Id relative_window_id, 1301 Id relative_window_id,
1288 mojom::OrderDirection direction) { 1302 mojom::OrderDirection direction) {
1289 // TODO(erg): This implementation allows reordering two windows that are 1303 // TODO(erg): This implementation allows reordering two windows that are
1290 // children of a parent window which the two implementations can't see. There 1304 // children of a parent window which the two implementations can't see. There
1291 // should be a security check to prevent this. 1305 // should be a security check to prevent this.
1292 bool success = false; 1306 bool success = false;
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 2170 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2157 effect_bitmask, callback); 2171 effect_bitmask, callback);
2158 } 2172 }
2159 2173
2160 void WindowTree::PerformOnDragDropDone() { 2174 void WindowTree::PerformOnDragDropDone() {
2161 client()->OnDragDropDone(); 2175 client()->OnDragDropDone();
2162 } 2176 }
2163 2177
2164 } // namespace ws 2178 } // namespace ws
2165 } // namespace ui 2179 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698