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

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: rebase 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 b77fcfa9ca54065458e5d5da8f8f8d95af437a59..0114bf5e89484c2ea0a5aa308e023c9861395187 100644
--- a/components/mus/ws/window_tree.cc
+++ b/components/mus/ws/window_tree.cc
@@ -15,6 +15,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"
@@ -954,9 +955,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_);
- client()->OnWindowInputEvent(event_ack_id_,
- ClientWindowIdForWindow(target).id,
- mojom::Event::From(event));
+ bool matched_observer =
+ event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event);
+ client()->OnWindowInputEvent(
+ event_ack_id_, ClientWindowIdForWindow(target).id,
+ mojom::Event::From(event), matched_observer ? event_observer_id_ : 0);
+}
+
+void WindowTree::SendToEventObserver(const ui::Event& event) {
+ if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event))
+ client()->OnEventObserved(mojom::Event::From(event), event_observer_id_);
}
void WindowTree::NewWindow(
@@ -1112,6 +1120,17 @@ void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
client()->OnChangeCompleted(change_id, success);
}
+void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher,
+ uint32_t observer_id) {
+ if (!matcher.is_null() && observer_id != 0) {
+ event_observer_matcher_.reset(new EventMatcher(*matcher));
+ event_observer_id_ = observer_id;
+ } else {
+ event_observer_matcher_.reset();
+ event_observer_id_ = 0;
+ }
+}
+
void WindowTree::SetWindowBounds(uint32_t change_id,
Id window_id,
mojo::RectPtr bounds) {

Powered by Google App Engine
This is Rietveld 408576698