| Index: components/mus/ws/window_manager_state.cc
|
| diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc
|
| index b28716005977f1d07a0ca2b0723b2daec27c7a9c..51a08e253baecd7872f0181f77c0fe1fefaa31ee 100644
|
| --- a/components/mus/ws/window_manager_state.cc
|
| +++ b/components/mus/ws/window_manager_state.cc
|
| @@ -55,6 +55,14 @@ std::unique_ptr<ui::Event> CoalesceEvents(std::unique_ptr<ui::Event> first,
|
| return second;
|
| }
|
|
|
| +ServerWindow* GetEmbedRoot(ServerWindow* window) {
|
| + DCHECK(window);
|
| + ServerWindow* embed_root = window->parent();
|
| + while (embed_root && embed_root->id().client_id == window->id().client_id)
|
| + embed_root = embed_root->parent();
|
| + return embed_root;
|
| +}
|
| +
|
| } // namespace
|
|
|
| class WindowManagerState::ProcessedEventTarget {
|
| @@ -297,22 +305,29 @@ void WindowManagerState::DispatchInputEventToWindowImpl(
|
| }
|
|
|
| // If the event is in the non-client area the event goes to the owner of
|
| - // the window. Otherwise if the window is an embed root, forward to the
|
| - // embedded window.
|
| - WindowTree* tree =
|
| - in_nonclient_area
|
| - ? window_server()->GetTreeWithId(target->id().client_id)
|
| - : window_server()->GetTreeWithRoot(target);
|
| - if (!tree) {
|
| - if (in_nonclient_area) {
|
| - // Being the root of the tree means we may get events outside the bounds
|
| - // of the platform window. Because the root has a client id of 0,
|
| - // no WindowTree is found for it and we have to special case it here.
|
| - DCHECK_EQ(target, root_.get());
|
| - tree = tree_;
|
| - } else {
|
| + // the window.
|
| + WindowTree* tree = nullptr;
|
| + if (in_nonclient_area) {
|
| + tree = window_server()->GetTreeWithId(target->id().client_id);
|
| + } else {
|
| + // If the window is an embed root, forward to the embedded window.
|
| + tree = window_server()->GetTreeWithRoot(target);
|
| + if (!tree)
|
| tree = window_server()->GetTreeWithId(target->id().client_id);
|
| - }
|
| + }
|
| +
|
| + ServerWindow* embed_root =
|
| + tree->HasRoot(target) ? target : GetEmbedRoot(target);
|
| + while (tree && tree->embedder_intercepts_events()) {
|
| + DCHECK(tree->HasRoot(embed_root));
|
| + tree = window_server()->GetTreeWithId(embed_root->id().client_id);
|
| + embed_root = GetEmbedRoot(embed_root);
|
| + }
|
| +
|
| + if (!tree) {
|
| + DCHECK(in_nonclient_area);
|
| + DCHECK_EQ(target, root_.get());
|
| + tree = tree_;
|
| }
|
|
|
| // TOOD(sad): Adjust this delay, possibly make this dynamic.
|
|
|