Index: ui/views/mus/window_manager_connection.cc |
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc |
index d5f3670520cdf5f3aef280027b0d4184d1b8cbd6..1cbbc1d925b801aa53da0f21cc2b640c3b8022d4 100644 |
--- a/ui/views/mus/window_manager_connection.cc |
+++ b/ui/views/mus/window_manager_connection.cc |
@@ -20,6 +20,7 @@ |
#include "ui/views/mus/native_widget_mus.h" |
#include "ui/views/mus/screen_mus.h" |
#include "ui/views/pointer_watcher.h" |
+#include "ui/views/touch_event_watcher.h" |
#include "ui/views/views_delegate.h" |
namespace views { |
@@ -100,6 +101,26 @@ void WindowManagerConnection::RemovePointerWatcher(PointerWatcher* watcher) { |
} |
} |
+void WindowManagerConnection::AddTouchEventWatcher(TouchEventWatcher* watcher) { |
+ bool had_watcher = HasTouchEventWatcher(); |
+ touch_event_watchers_.AddObserver(watcher); |
+ if (!had_watcher) { |
+ ui::mojom::EventMatcherPtr matcher = ui::mojom::EventMatcher::New(); |
+ matcher->pointer_kind_matcher = ui::mojom::PointerKindMatcher::New(); |
+ matcher->pointer_kind_matcher->pointer_kind = ui::mojom::PointerKind::TOUCH; |
+ client_->SetEventObserver(std::move(matcher)); |
sky
2016/07/06 20:22:02
Notice how this now conflicts with 92. In an effor
riajiang
2016/07/08 02:51:40
Done.
|
+ } |
+} |
+ |
+void WindowManagerConnection::RemoveTouchEventWatcher( |
+ TouchEventWatcher* watcher) { |
+ touch_event_watchers_.RemoveObserver(watcher); |
+ if (!HasTouchEventWatcher()) { |
+ // Last PointerWatcher removed, stop the event observer. |
+ client_->SetEventObserver(nullptr); |
+ } |
+} |
+ |
WindowManagerConnection::WindowManagerConnection( |
shell::Connector* connector, |
const shell::Identity& identity) |
@@ -142,6 +163,15 @@ bool WindowManagerConnection::HasPointerWatcher() { |
return !!iterator.GetNext(); |
} |
+bool WindowManagerConnection::HasTouchEventWatcher() { |
+ // Check to see if we really have any observers left. This doesn't use |
+ // base::ObserverList<>::might_have_observers() because that returns true |
+ // during iteration over the list even when the last observer is removed. |
+ base::ObserverList<TouchEventWatcher>::Iterator iterator( |
+ &touch_event_watchers_); |
+ return !!iterator.GetNext(); |
+} |
+ |
void WindowManagerConnection::OnEmbed(ui::Window* root) {} |
void WindowManagerConnection::OnDidDestroyClient(ui::WindowTreeClient* client) { |
@@ -174,6 +204,11 @@ void WindowManagerConnection::OnEventObserved(const ui::Event& event, |
FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, |
OnTouchPressed(*event.AsTouchEvent(), location_in_screen, |
target_widget)); |
+ } else if (event.IsTouchPointerEvent()) { |
+ FOR_EACH_OBSERVER(TouchEventWatcher, touch_event_watchers_, |
+ OnTouchEventObserved(*event.AsLocatedEvent(), |
+ location_in_screen, |
+ target_widget)); |
} |
} |