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

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

Issue 2170053003: mash: Don't crash when dragging a window to the side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_manager_state.h" 5 #include "services/ui/ws/window_manager_state.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "services/shell/public/interfaces/connector.mojom.h" 8 #include "services/shell/public/interfaces/connector.mojom.h"
9 #include "services/ui/common/event_matcher_util.h" 9 #include "services/ui/common/event_matcher_util.h"
10 #include "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 WindowTree* tree = nullptr; 489 WindowTree* tree = nullptr;
490 if (in_nonclient_area) { 490 if (in_nonclient_area) {
491 tree = window_server()->GetTreeWithId(window->id().client_id); 491 tree = window_server()->GetTreeWithId(window->id().client_id);
492 } else { 492 } else {
493 // If the window is an embed root, forward to the embedded window. 493 // If the window is an embed root, forward to the embedded window.
494 tree = window_server()->GetTreeWithRoot(window); 494 tree = window_server()->GetTreeWithRoot(window);
495 if (!tree) 495 if (!tree)
496 tree = window_server()->GetTreeWithId(window->id().client_id); 496 tree = window_server()->GetTreeWithId(window->id().client_id);
497 } 497 }
498 498
499 const ServerWindow* embed_root = 499 if (tree) {
500 tree->HasRoot(window) ? window : GetEmbedRoot(window); 500 const ServerWindow* embed_root =
501 while (tree && tree->embedder_intercepts_events()) { 501 tree->HasRoot(window) ? window : GetEmbedRoot(window);
502 DCHECK(tree->HasRoot(embed_root)); 502 while (tree && tree->embedder_intercepts_events()) {
503 tree = window_server()->GetTreeWithId(embed_root->id().client_id); 503 DCHECK(tree->HasRoot(embed_root));
504 embed_root = GetEmbedRoot(embed_root); 504 tree = window_server()->GetTreeWithId(embed_root->id().client_id);
505 embed_root = GetEmbedRoot(embed_root);
506 }
505 } 507 }
506 508
507 if (!tree) { 509 if (!tree) {
508 DCHECK(in_nonclient_area); 510 DCHECK(in_nonclient_area);
509 tree = window_tree_; 511 tree = window_tree_;
510 } 512 }
511 return tree->id(); 513 return tree->id();
512 } 514 }
513 515
514 ServerWindow* WindowManagerState::GetRootWindowContaining( 516 ServerWindow* WindowManagerState::GetRootWindowContaining(
515 const gfx::Point& location) { 517 const gfx::Point& location) {
516 if (display_manager()->displays().empty()) 518 if (display_manager()->displays().empty())
517 return nullptr; 519 return nullptr;
518 520
519 // TODO(sky): this isn't right. To correctly implement need bounds of 521 // TODO(sky): this isn't right. To correctly implement need bounds of
520 // Display, which we aren't tracking yet. For now, use the first display. 522 // Display, which we aren't tracking yet. For now, use the first display.
521 Display* display = *(display_manager()->displays().begin()); 523 Display* display = *(display_manager()->displays().begin());
522 WindowManagerDisplayRoot* display_root = 524 WindowManagerDisplayRoot* display_root =
523 display->GetWindowManagerDisplayRootForUser(user_id()); 525 display->GetWindowManagerDisplayRootForUser(user_id());
524 return display_root ? display_root->root() : nullptr; 526 return display_root ? display_root->root() : nullptr;
525 } 527 }
526 528
527 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 529 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
528 window_server()->SendToEventObservers(event, user_id(), 530 window_server()->SendToEventObservers(event, user_id(),
529 nullptr /* ignore_tree */); 531 nullptr /* ignore_tree */);
530 } 532 }
531 533
532 } // namespace ws 534 } // namespace ws
533 } // namespace ui 535 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698