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

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

Issue 2710023007: Make WindowTree::SetModal() take the type. (Closed)
Patch Set: Fix compile error. 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
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::SetModal(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 // TODO(moshayedi): crbug.com/697176. When modality of a window that used to
360 if (window->transient_parent()) { 361 // be a system modal changes, notify window manager state.
361 window->SetModal(); 362 auto* display_root = GetWindowManagerDisplayRoot(window);
362 } else if (user_id_ != InvalidUserId()) { 363 switch (modal_type) {
sky 2017/03/01 00:13:35 Early out if modal_type matches?
Hadi 2017/03/06 20:07:05 Done. Should we return true or false in this case?
sky 2017/03/06 22:26:45 Return true.
363 if (display_root) 364 case MODAL_TYPE_NONE:
sky 2017/03/01 00:13:35 Move this to MODEL_TYPE_WINDOW as it's the same im
Hadi 2017/03/06 20:07:05 I thought we shouldn't release capture when MODAL_
364 display_root->window_manager_state()->AddSystemModalWindow(window); 365 window->SetModal(MODAL_TYPE_NONE);
365 } else { 366 return true;
366 return false; 367 case MODAL_TYPE_SYSTEM:
367 } 368 if (user_id_ == InvalidUserId() || !display_root)
sky 2017/03/01 00:13:35 Why the InvalidUserId check?
Hadi 2017/03/06 20:07:05 The previous implementation checks for InvalidUser
368 if (display_root) 369 return false;
369 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow( 370 display_root->window_manager_state()->AddSystemModalWindow(window);
sky 2017/03/01 00:13:35 How come you don't SetModal(modal_type) in this ca
Hadi 2017/03/06 20:07:05 AddSystemModalWindow() does this. I agree my imple
370 window); 371 break;
371 return true; 372 case MODAL_TYPE_WINDOW:
373 case MODAL_TYPE_CHILD:
374 window->SetModal(modal_type);
375 break;
372 } 376 }
373 return false; 377 if (display_root) {
378 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow(
379 window);
380 }
381 return true;
374 } 382 }
375 383
376 std::vector<const ServerWindow*> WindowTree::GetWindowTree( 384 std::vector<const ServerWindow*> WindowTree::GetWindowTree(
377 const ClientWindowId& window_id) const { 385 const ClientWindowId& window_id) const {
378 const ServerWindow* window = GetWindowByClientId(window_id); 386 const ServerWindow* window = GetWindowByClientId(window_id);
379 std::vector<const ServerWindow*> windows; 387 std::vector<const ServerWindow*> windows;
380 if (window) 388 if (window)
381 GetWindowTreeImpl(window, &windows); 389 GetWindowTreeImpl(window, &windows);
382 return windows; 390 return windows;
383 } 391 }
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { 1279 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) {
1272 success = true; 1280 success = true;
1273 Operation op(this, window_server_, 1281 Operation op(this, window_server_,
1274 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); 1282 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT);
1275 transient_window->transient_parent()->RemoveTransientWindow( 1283 transient_window->transient_parent()->RemoveTransientWindow(
1276 transient_window); 1284 transient_window);
1277 } 1285 }
1278 client()->OnChangeCompleted(change_id, success); 1286 client()->OnChangeCompleted(change_id, success);
1279 } 1287 }
1280 1288
1281 void WindowTree::SetModal(uint32_t change_id, Id window_id) { 1289 void WindowTree::SetModal(uint32_t change_id,
1282 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id))); 1290 Id window_id,
1291 ModalType modal_type) {
1292 client()->OnChangeCompleted(change_id,
1293 SetModal(ClientWindowId(window_id), modal_type));
1283 } 1294 }
1284 1295
1285 void WindowTree::ReorderWindow(uint32_t change_id, 1296 void WindowTree::ReorderWindow(uint32_t change_id,
1286 Id window_id, 1297 Id window_id,
1287 Id relative_window_id, 1298 Id relative_window_id,
1288 mojom::OrderDirection direction) { 1299 mojom::OrderDirection direction) {
1289 // TODO(erg): This implementation allows reordering two windows that are 1300 // TODO(erg): This implementation allows reordering two windows that are
1290 // children of a parent window which the two implementations can't see. There 1301 // children of a parent window which the two implementations can't see. There
1291 // should be a security check to prevent this. 1302 // should be a security check to prevent this.
1292 bool success = false; 1303 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, 2167 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2157 effect_bitmask, callback); 2168 effect_bitmask, callback);
2158 } 2169 }
2159 2170
2160 void WindowTree::PerformOnDragDropDone() { 2171 void WindowTree::PerformOnDragDropDone() {
2161 client()->OnDragDropDone(); 2172 client()->OnDragDropDone();
2162 } 2173 }
2163 2174
2164 } // namespace ws 2175 } // namespace ws
2165 } // namespace ui 2176 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698