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

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

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 8 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_tree.cc
diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc
index 863a3a13e61a2095581b0f08fac3b089e39daa76..e1d719037db896469856d3e18147ade9db36694a 100644
--- a/components/mus/ws/window_tree.cc
+++ b/components/mus/ws/window_tree.cc
@@ -13,6 +13,7 @@
#include "components/mus/ws/default_access_policy.h"
#include "components/mus/ws/display.h"
#include "components/mus/ws/display_manager.h"
+#include "components/mus/ws/event_matcher.h"
#include "components/mus/ws/focus_controller.h"
#include "components/mus/ws/operation.h"
#include "components/mus/ws/platform_display.h"
@@ -951,9 +952,16 @@ void WindowTree::DispatchInputEventImpl(ServerWindow* target,
event_source_wms_ = GetWindowManagerState(target);
// Should only get events from windows attached to a host.
DCHECK(event_source_wms_);
+ bool matched_observer =
+ event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event);
client()->OnWindowInputEvent(event_ack_id_,
ClientWindowIdForWindow(target).id,
- mojom::Event::From(event));
+ mojom::Event::From(event), matched_observer);
+}
+
+void WindowTree::SendToEventObserver(const ui::Event& event) {
+ if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event))
+ client()->OnEventObserved(mojom::Event::From(event));
}
void WindowTree::NewWindow(
@@ -1109,6 +1117,13 @@ void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
client()->OnChangeCompleted(change_id, success);
}
+void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher) {
+ if (!matcher.is_null())
+ event_observer_matcher_.reset(new EventMatcher(*matcher));
+ else
+ event_observer_matcher_.reset();
+}
+
void WindowTree::SetWindowBounds(uint32_t change_id,
Id window_id,
mojo::RectPtr bounds) {

Powered by Google App Engine
This is Rietveld 408576698