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

Unified Diff: services/ui/ws/window_tree.cc

Issue 2180683003: NOSUBMIT: PointerWatcher observes all pointer events, with moves optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « services/ui/ws/window_tree.h ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/window_tree.cc
diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc
index 0206327b3029fe4a72b98b55812605d6bcc98571..c13e5602c2cb225b287390871917f01765c8c59c 100644
--- a/services/ui/ws/window_tree.cc
+++ b/services/ui/ws/window_tree.cc
@@ -987,16 +987,26 @@ void WindowTree::DispatchInputEventImpl(ServerWindow* target,
event_source_wms_ = display_root->window_manager_state();
// 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);
+ bool matched_pointer_watcher = EventMatchesPointerWatcher(event);
client()->OnWindowInputEvent(
event_ack_id_, ClientWindowIdForWindow(target).id,
- ui::Event::Clone(event), matched_observer ? event_observer_id_ : 0);
+ ui::Event::Clone(event),
+ matched_pointer_watcher ? pointer_watcher_id_ : 0);
+}
+
+bool WindowTree::EventMatchesPointerWatcher(const ui::Event& event) {
+ if (!has_pointer_watcher_)
+ return false;
+ if (!event.IsPointerEvent())
+ return false;
+ if (!pointer_watcher_want_moves_ && event.type() == ui::ET_POINTER_MOVED)
+ return false;
+ return true;
}
void WindowTree::SendToEventObserver(const ui::Event& event) {
- if (event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event))
- client()->OnEventObserved(ui::Event::Clone(event), event_observer_id_);
+ if (EventMatchesPointerWatcher(event))
+ client()->OnEventObserved(ui::Event::Clone(event), pointer_watcher_id_);
}
void WindowTree::NewWindow(
@@ -1164,48 +1174,20 @@ void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher,
uint32_t observer_id) {
- if (matcher.is_null() || observer_id == 0) {
- // Clear any existing event observer.
- event_observer_matcher_.reset();
- event_observer_id_ = 0;
- return;
- }
-
- // Do not allow key events to be observed, as a compromised app could register
- // itself as an event observer and spy on keystrokes to another app.
- if (!matcher->type_matcher && !matcher->pointer_kind_matcher) {
- DVLOG(1) << "SetEventObserver must specify an event type.";
- return;
- }
+ // JAMES - remove this function
+}
- const ui::mojom::EventType event_type_whitelist[] = {
- ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN,
- ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP,
- ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL,
- };
-
- if (matcher->type_matcher) {
- auto iter =
- std::find(std::begin(event_type_whitelist),
- std::end(event_type_whitelist), matcher->type_matcher->type);
- if (iter == std::end(event_type_whitelist)) {
- DVLOG(1) << "SetEventObserver event type not allowed";
- return;
- }
- }
- if (matcher->pointer_kind_matcher) {
- ui::mojom::PointerKind pointer_kind =
- matcher->pointer_kind_matcher->pointer_kind;
- if (pointer_kind != ui::mojom::PointerKind::MOUSE &&
- pointer_kind != ui::mojom::PointerKind::TOUCH &&
- pointer_kind != ui::mojom::PointerKind::PEN) {
- DVLOG(1) << "SetEventObserver pointer kind not allowed";
- return;
- }
- }
+void WindowTree::StartPointerWatcher(bool want_moves,
+ uint32_t pointer_watcher_id) {
+ has_pointer_watcher_ = true;
+ pointer_watcher_want_moves_ = want_moves;
+ pointer_watcher_id_ = pointer_watcher_id;
+}
- event_observer_matcher_.reset(new EventMatcher(*matcher));
- event_observer_id_ = observer_id;
+void WindowTree::StopPointerWatcher() {
+ has_pointer_watcher_ = false;
+ pointer_watcher_want_moves_ = false;
+ pointer_watcher_id_ = 0;
}
void WindowTree::SetWindowBounds(uint32_t change_id,
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698