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

Unified Diff: services/native_viewport/native_viewport_impl.cc

Issue 1033513003: Cleans up events to just the parts we're actually using (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 5 years, 9 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/native_viewport/native_viewport_impl.h ('k') | services/native_viewport/platform_viewport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/native_viewport/native_viewport_impl.cc
diff --git a/services/native_viewport/native_viewport_impl.cc b/services/native_viewport/native_viewport_impl.cc
index 09b5be3cd397dbd1084b5e2b16fdb14340daa646..62f6ca22d83c590ce79acc269c82fbe4d8e35d47 100644
--- a/services/native_viewport/native_viewport_impl.cc
+++ b/services/native_viewport/native_viewport_impl.cc
@@ -19,10 +19,8 @@
namespace native_viewport {
namespace {
-bool IsRateLimitedEventType(ui::Event* event) {
- return event->type() == ui::ET_MOUSE_MOVED ||
- event->type() == ui::ET_MOUSE_DRAGGED ||
- event->type() == ui::ET_TOUCH_MOVED;
+bool IsRateLimitedEventType(const mojo::EventPtr& event) {
+ return event->action == mojo::EVENT_TYPE_POINTER_MOVE;
}
} // namespace
@@ -123,29 +121,14 @@ void NativeViewportImpl::OnAcceleratedWidgetDestroyed() {
context_provider_.SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
}
-bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
- if (!event_dispatcher_.get())
+bool NativeViewportImpl::OnEvent(mojo::EventPtr event) {
+ if (event.is_null() || !event_dispatcher_.get() ||
+ (waiting_for_event_ack_ && IsRateLimitedEventType(event))) {
return false;
-
- // Must not return early before updating capture.
- switch (ui_event->type()) {
- case ui::ET_MOUSE_PRESSED:
- case ui::ET_TOUCH_PRESSED:
- platform_viewport_->SetCapture();
- break;
- case ui::ET_MOUSE_RELEASED:
- case ui::ET_TOUCH_RELEASED:
- platform_viewport_->ReleaseCapture();
- break;
- default:
- break;
}
- if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event))
- return false;
-
event_dispatcher_->OnEvent(
- mojo::Event::From(*ui_event),
+ event.Pass(),
base::Bind(&NativeViewportImpl::AckEvent, weak_factory_.GetWeakPtr()));
waiting_for_event_ack_ = true;
return false;
« no previous file with comments | « services/native_viewport/native_viewport_impl.h ('k') | services/native_viewport/platform_viewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698