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

Unified Diff: components/mus/ws/window_manager_state.cc

Issue 2068093002: mus: Allow embedder to intercept events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698