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

Unified Diff: ui/events/x/device_data_manager_x11.h

Issue 688253002: Implemented smooth scrolling using xinput2 in X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied sadrul's comments Created 6 years 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/x/device_data_manager_x11.h
diff --git a/ui/events/x/device_data_manager_x11.h b/ui/events/x/device_data_manager_x11.h
index 02da999a1cdffcc3e89bf43bade9d82183e6ca3c..13903209d39bba99b8b9e85878826a68dd8c62c2 100644
--- a/ui/events/x/device_data_manager_x11.h
+++ b/ui/events/x/device_data_manager_x11.h
@@ -40,6 +40,30 @@ enum GestureMetricsType {
kGestureMetricsTypeUnknown,
};
+// Information about scroll valuators
+struct ScrollInfo {
+ struct AxisInfo {
+ // The scroll valuator number of this scroll axis.
+ int number;
+ // The scroll increment; a value of n indicates n movement equals one
+ // traditional scroll unit.
+ double increment;
+ // Current scroll position; used to find the difference between events.
+ double position;
+ // If true then scroll has been seen in this direction.
+ bool seen;
+ };
+
+ AxisInfo vertical, horizontal;
+};
+
+// A bitfield describing which scroll axes are enabled for a device.
+enum ScrollType {
+ SCROLL_TYPE_NO_SCROLL = 0,
+ SCROLL_TYPE_HORIZONTAL = 1 << 0,
+ SCROLL_TYPE_VERTICAL = 1 << 1,
+};
+
// A class that extracts and tracks the input events data. It currently handles
// mouse, touchpad and touchscreen devices.
class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
@@ -149,6 +173,16 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// is a CMT event (e.g. it could be a mouse pointer move).
bool IsCMTDeviceEvent(const base::NativeEvent& native_event) const;
+ // Check if the event contains information about a ScrollClass, and
+ // report which scroll axes are contained in this event, defined by
+ // ScrollInfo.
+ int GetScrollClassEventDetail(const base::NativeEvent& native_event) const;
+
+ // Check if the event comes from a device that has a ScrollClass, and
+ // report which scroll axes it supports as a bit field, defined by
+ // ScrollInfo.
+ int GetScrollClassDeviceDetail(const base::NativeEvent& native_event) const;
+
// Check if the event is one of the CMT gesture events (scroll, fling,
// metrics etc.).
bool IsCMTGestureEvent(const base::NativeEvent& native_event) const;
@@ -171,6 +205,17 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
float* y_offset_ordinal,
int* finger_count);
+ // Extract data from a scroll class event (smooth scrolling). User must
+ // first verify the event type with GetScrollClassEventDetail.
+ // Pointers shouldn't be NULL.
+ void GetScrollClassOffsets(const base::NativeEvent& native_event,
+ double* x_offset,
+ double* y_offset);
+
+ // Invalidate stored scroll class counters, since they can change when
+ // pointing at other windows.
+ void InvalidateScrollClasses();
+
// Extract data from a fling event. User must first verify the event type
// with IsFlingEvent. Pointers shouldn't be NULL.
void GetFlingData(const base::NativeEvent& native_event,
@@ -208,6 +253,15 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
const DataType type,
double* value);
+ // Normalize the scroll amount according to the increment size.
+ // *value /= increment
+ // *value is expected to be 1 or -1.
+ // Returns true and sets the normalized value in |value| if normalization is
+ // successful. Returns false and |value| is unchanged otherwise.
+ bool NormalizeScrollData(unsigned int deviceid,
+ bool horizontal,
+ double* value);
+
// Extract the range of the data type. Return true if the range is available
// and written into min & max, false if the range is not available.
bool GetDataRange(unsigned int deviceid,
@@ -273,6 +327,7 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// should be processed.
std::bitset<kMaxDeviceNum> cmt_devices_;
std::bitset<kMaxDeviceNum> touchpads_;
+ std::bitset<kMaxDeviceNum> scrollclass_devices_;
// A quick lookup table for determining if events from the XI device
// should be blocked.
@@ -288,6 +343,10 @@ class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// by valuator_lookup_[device_id][data_type].
std::vector<int> valuator_lookup_[kMaxDeviceNum];
+ // Index table to find the horizontal and vertical scroll valuator
+ // numbers, scroll increments and scroll position.
+ ScrollInfo scroll_data_[kMaxDeviceNum];
+
// Index table to find the DataType for valuator on the specific device
// by data_type_lookup_[device_id][valuator].
std::vector<int> data_type_lookup_[kMaxDeviceNum];

Powered by Google App Engine
This is Rietveld 408576698