| 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
|
|
|