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

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: tot-merge 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
« no previous file with comments | « components/mus/ws/test_utils.cc ('k') | components/mus/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8139b49a6d7fe4a01e87f7f18c4d1d2a129b52b4..b394514bef2b48bec9404fae185ebc6d8b9af0fc 100644
--- a/components/mus/ws/window_manager_state.cc
+++ b/components/mus/ws/window_manager_state.cc
@@ -54,6 +54,14 @@ std::unique_ptr<ui::Event> CoalesceEvents(std::unique_ptr<ui::Event> first,
return second;
}
+const ServerWindow* GetEmbedRoot(const ServerWindow* window) {
+ DCHECK(window);
+ const 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 {
@@ -428,18 +436,29 @@ void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target,
ClientSpecificId WindowManagerState::GetEventTargetClientId(
const ServerWindow* window,
bool in_nonclient_area) {
- WindowTree* tree =
- in_nonclient_area ? window_server()->GetTreeWithId(window->id().client_id)
- : window_server()->GetTreeWithRoot(window);
- 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.
- tree = window_tree_;
- } else {
+ // If the event is in the non-client area the event goes to the owner of
+ // the window.
+ WindowTree* tree = nullptr;
+ if (in_nonclient_area) {
+ tree = window_server()->GetTreeWithId(window->id().client_id);
+ } else {
+ // If the window is an embed root, forward to the embedded window.
+ tree = window_server()->GetTreeWithRoot(window);
+ if (!tree)
tree = window_server()->GetTreeWithId(window->id().client_id);
- }
+ }
+
+ const ServerWindow* embed_root =
+ tree->HasRoot(window) ? window : GetEmbedRoot(window);
+ 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);
+ tree = window_tree_;
}
return tree->id();
}
« no previous file with comments | « components/mus/ws/test_utils.cc ('k') | components/mus/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698