Chromium Code Reviews| Index: ui/events/devices/x11/device_data_manager_x11.h |
| diff --git a/ui/events/devices/x11/device_data_manager_x11.h b/ui/events/devices/x11/device_data_manager_x11.h |
| index 38cb7810517a3bfa137b7832aba39f38ea11698a..01a9f5ff25775f872fb387973820b8f7eddb5c2a 100644 |
| --- a/ui/events/devices/x11/device_data_manager_x11.h |
| +++ b/ui/events/devices/x11/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_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager { |
| @@ -119,6 +143,16 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager { |
| // Updates the list of devices. |
| void UpdateDeviceList(Display* display); |
| + // Updates a device based on a Valuator class info. Returns true if the |
| + // device is a possible CMT device. |
| + bool UpdateValuatorClassDevice(XIValuatorClassInfo* valuator_class_info, |
| + Atom *atoms, |
| + int deviceid); |
|
sadrul
2015/08/18 16:57:46
This doesn't need to be public, does it?
Will Shackleton
2015/08/26 19:52:48
Acknowledged.
|
| + |
| + // Updates a device based on a Scroll class info. |
| + void UpdateScrollClassDevice(XIScrollClassInfo* scroll_class_info, |
| + int deviceid); |
|
sadrul
2015/08/18 16:57:46
ditto
Will Shackleton
2015/08/26 19:52:48
Acknowledged.
|
| + |
| // For multitouch events we use slot number to distinguish touches from |
| // different fingers. This function returns true if the associated slot |
| // for |xiev| can be found and it is saved in |slot|, returns false if |
| @@ -149,6 +183,16 @@ class EVENTS_DEVICES_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 +215,17 @@ class EVENTS_DEVICES_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 +263,15 @@ class EVENTS_DEVICES_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(int deviceid, |
| @@ -277,6 +341,7 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager { |
| // should be processed. |
| std::bitset<kMaxDeviceNum> cmt_devices_; |
| std::bitset<kMaxDeviceNum> touchpads_; |
| + std::bitset<kMaxDeviceNum> scrollclass_devices_; |
| // List of the master pointer devices. |
| std::vector<int> master_pointers_; |
| @@ -295,6 +360,10 @@ class EVENTS_DEVICES_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]; |