Index: ui/events/ozone/evdev/palm_suppression_filter.h |
diff --git a/ui/events/ozone/evdev/palm_suppression_filter.h b/ui/events/ozone/evdev/palm_suppression_filter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9acc286c3ef2e59838f25a02618c26a73a1c0ac1 |
--- /dev/null |
+++ b/ui/events/ozone/evdev/palm_suppression_filter.h |
@@ -0,0 +1,57 @@ |
+// 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. |
+ |
+#ifndef UI_EVENTS_OZONE_EVDEV_PALM_SUPPRESSION_FILTER_H_ |
+#define UI_EVENTS_OZONE_EVDEV_PALM_SUPPRESSION_FILTER_H_ |
+ |
+#include <bitset> |
+#include <set> |
+ |
+#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
+#include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
+#include "ui/events/ozone/evdev/touch_evdev_types.h" |
+ |
+namespace ui { |
+ |
+class DeviceEventDispatcherEvdev; |
+ |
+class EVENTS_OZONE_EVDEV_EXPORT PalmSuppressionFilter { |
+ public: |
+ explicit PalmSuppressionFilter(DeviceEventDispatcherEvdev* dispatcher); |
+ virtual ~PalmSuppressionFilter(); |
+ |
+ // Returns true if the touch event should be dispatched by the caller. |
+ bool FilterTouch(const TouchEventParams& params); |
+ |
+ // Enable palm suppression. Might generate cancel events for existing |
+ // touches. |
+ void EnableSuppression(bool enabled, base::TimeTicks timestamp); |
+ |
+ // Reset the filter to a clean state which allows all touches. |
+ void Reset(); |
+ |
+ private: |
+ void CancelExistingTouches(base::TimeTicks timestamp); |
+ |
+ DeviceEventDispatcherEvdev* dispatcher_; |
+ |
+ // Bitset of slots that are currently reported to the upper layers |
+ std::bitset<kNumTouchEvdevSlots> reported_slots_; |
+ |
+ // Device id of the touchscreen. Initialized with the first call to |
+ // FilterTouch. |
+ int touch_device_id_ = -1; |
+ |
+ // True when all touch input is currently being suppressed. |
+ bool suppressing_ = false; |
+ |
+ // True when all touch input is supposed to pass through. |
+ bool pass_through_ = true; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PalmSuppressionFilter); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_EVENTS_OZONE_EVDEV_PALM_SUPPRESSION_FILTER_H_ |