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

Unified Diff: ui/events/ozone/evdev/palm_suppression_filter.cc

Issue 2263693003: Add palm suppression feature to EventConverterEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stylus
Patch Set: use touch major = max to recognize palms Created 4 years, 4 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: ui/events/ozone/evdev/palm_suppression_filter.cc
diff --git a/ui/events/ozone/evdev/palm_suppression_filter.cc b/ui/events/ozone/evdev/palm_suppression_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..254f48abab10ea8b17253b65fde662ebda2c6a46
--- /dev/null
+++ b/ui/events/ozone/evdev/palm_suppression_filter.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/ozone/evdev/palm_suppression_filter.h"
+
+namespace ui {
+
+PalmSuppressionFilter::PalmSuppressionFilter(
+ DeviceEventDispatcherEvdev* dispatcher)
+ : dispatcher_(dispatcher) {}
+
+PalmSuppressionFilter::~PalmSuppressionFilter() {}
+
+bool PalmSuppressionFilter::FilterTouch(const TouchEventParams& params) {
+ DCHECK(touch_device_id_ == -1 || touch_device_id_ == params.device_id);
+ touch_device_id_ = params.device_id;
+
+ if (params.type == ET_TOUCH_PRESSED) {
+ reported_slots_.set(params.slot);
+ }
+
+ bool dispatch = !suppressing_ && reported_slots_[params.slot];
+
+ if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) {
+ reported_slots_.reset(params.slot);
+ }
+ return pass_through_ || dispatch;
+}
+
+void PalmSuppressionFilter::Reset() {
+ suppressing_ = false;
+ pass_through_ = true;
+ reported_slots_.reset();
+}
+
+void PalmSuppressionFilter::EnableSuppression(bool enabled,
+ base::TimeTicks timestamp) {
+ if (!suppressing_ && enabled)
+ CancelExistingTouches(timestamp);
+ suppressing_ = enabled;
+}
+
+void PalmSuppressionFilter::CancelExistingTouches(base::TimeTicks timestamp) {
+ for (size_t i = 0; i < reported_slots_.size(); ++i) {
+ if (reported_slots_[i]) {
+ dispatcher_->DispatchTouchEvent(
+ TouchEventParams(touch_device_id_, i, ET_TOUCH_CANCELLED,
+ gfx::PointF(), ui::PointerDetails(), timestamp));
+ }
+ }
+ reported_slots_.reset();
+ pass_through_ = false;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698