Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "services/shell/public/interfaces/connector.mojom.h" | 10 #include "services/shell/public/interfaces/connector.mojom.h" |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 | 496 |
| 497 base::WeakPtr<Accelerator> weak_accelerator; | 497 base::WeakPtr<Accelerator> weak_accelerator; |
| 498 if (accelerator) | 498 if (accelerator) |
| 499 weak_accelerator = accelerator->GetWeakPtr(); | 499 weak_accelerator = accelerator->GetWeakPtr(); |
| 500 DispatchInputEventToWindowImpl(target, client_id, event, weak_accelerator); | 500 DispatchInputEventToWindowImpl(target, client_id, event, weak_accelerator); |
| 501 } | 501 } |
| 502 | 502 |
| 503 ClientSpecificId WindowManagerState::GetEventTargetClientId( | 503 ClientSpecificId WindowManagerState::GetEventTargetClientId( |
| 504 const ServerWindow* window, | 504 const ServerWindow* window, |
| 505 bool in_nonclient_area) { | 505 bool in_nonclient_area) { |
| 506 // If the event is in the non-client area the event goes to the owner of | 506 // If the event is in the non-client area the event goes to the owner of |
|
James Cook
2016/08/24 17:00:33
nit: Remove this comment
sky
2016/08/24 19:23:29
Done. In removing this comment I realized the code
| |
| 507 // the window. | 507 // the window. |
| 508 WindowTree* tree = nullptr; | 508 WindowTree* tree = nullptr; |
| 509 if (in_nonclient_area) { | 509 if (in_nonclient_area) { |
| 510 tree = window_server()->GetTreeWithId(window->id().client_id); | 510 // Events in the non-client area always go to the window manager. |
| 511 tree = window_tree_; | |
| 511 } else { | 512 } else { |
| 512 // If the window is an embed root, forward to the embedded window. | 513 // If the window is an embed root, forward to the embedded window. |
| 513 tree = window_server()->GetTreeWithRoot(window); | 514 tree = window_server()->GetTreeWithRoot(window); |
| 514 if (!tree) | 515 if (!tree) |
| 515 tree = window_server()->GetTreeWithId(window->id().client_id); | 516 tree = window_server()->GetTreeWithId(window->id().client_id); |
| 516 } | 517 DCHECK(tree); |
| 517 | 518 |
| 518 if (tree) { | |
| 519 const ServerWindow* embed_root = | 519 const ServerWindow* embed_root = |
| 520 tree->HasRoot(window) ? window : GetEmbedRoot(window); | 520 tree->HasRoot(window) ? window : GetEmbedRoot(window); |
| 521 while (tree && tree->embedder_intercepts_events()) { | 521 while (tree && tree->embedder_intercepts_events()) { |
| 522 DCHECK(tree->HasRoot(embed_root)); | 522 DCHECK(tree->HasRoot(embed_root)); |
| 523 tree = window_server()->GetTreeWithId(embed_root->id().client_id); | 523 tree = window_server()->GetTreeWithId(embed_root->id().client_id); |
| 524 embed_root = GetEmbedRoot(embed_root); | 524 embed_root = GetEmbedRoot(embed_root); |
| 525 } | 525 } |
| 526 } | 526 DCHECK(tree); |
| 527 | |
| 528 if (!tree) { | |
| 529 DCHECK(in_nonclient_area); | |
| 530 tree = window_tree_; | |
| 531 } | 527 } |
| 532 return tree->id(); | 528 return tree->id(); |
| 533 } | 529 } |
| 534 | 530 |
| 535 ServerWindow* WindowManagerState::GetRootWindowContaining( | 531 ServerWindow* WindowManagerState::GetRootWindowContaining( |
| 536 gfx::Point* location) { | 532 gfx::Point* location) { |
| 537 if (display_manager()->displays().empty()) | 533 if (display_manager()->displays().empty()) |
| 538 return nullptr; | 534 return nullptr; |
| 539 | 535 |
| 540 Display* target_display = nullptr; | 536 Display* target_display = nullptr; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 565 return display_root->root(); | 561 return display_root->root(); |
| 566 } | 562 } |
| 567 | 563 |
| 568 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { | 564 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |
| 569 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ | 565 window_server()->SendToPointerWatchers(event, user_id(), nullptr, /* window */ |
| 570 nullptr /* ignore_tree */); | 566 nullptr /* ignore_tree */); |
| 571 } | 567 } |
| 572 | 568 |
| 573 } // namespace ws | 569 } // namespace ws |
| 574 } // namespace ui | 570 } // namespace ui |
| OLD | NEW |