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

Unified Diff: ui/events/devices/x11/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: Fixed device hotplugging, initialised variable Created 5 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/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 314946befc313051ffb2628b9f32713186d6cb1d..e3a72a1e167818706a790f14614bd386491f229b 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 {
sadrul 2016/01/04 18:51:21 Looks like ScrollInfo doesn't need to be part of t
Will Shackleton 2016/01/04 21:07:42 Acknowledged.
+ 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 {
@@ -152,6 +176,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.
sadrul 2016/01/04 18:51:21 defined by *ScrollType, right?
Will Shackleton 2016/01/04 21:07:42 Acknowledged.
+ 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.
sadrul 2016/01/04 18:51:21 ditto
+ 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;
@@ -174,6 +208,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,
@@ -211,6 +256,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,
@@ -267,6 +321,16 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
double min_value,
double max_value);
+ // 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);
+
+ // Updates a device based on a Scroll class info.
+ void UpdateScrollClassDevice(XIScrollClassInfo* scroll_class_info,
+ int deviceid);
+
static const int kMaxXIEventType = XI_LASTEVENT + 1;
static const int kMaxSlotNum = 10;
@@ -280,6 +344,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_;
@@ -298,6 +363,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];

Powered by Google App Engine
This is Rietveld 408576698