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

Side by Side Diff: ui/events/x/device_data_manager_x11.h

Issue 618283003: Adds special support to the device manager for keyboards devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change in ozone. Created 6 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ 5 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_
6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ 6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_
7 7
8 // Generically-named #defines from Xlib is conflicting with symbols in GTest. 8 // Generically-named #defines from Xlib is conflicting with symbols in GTest.
9 // So many tests .cc file #undef Bool before including device_data_manager.h, 9 // So many tests .cc file #undef Bool before including device_data_manager.h,
10 // which makes Bool unrecognized in XInput2.h. 10 // which makes Bool unrecognized in XInput2.h.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager { 44 class EVENTS_BASE_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
45 public: 45 public:
46 // Enumerate additional data that one might be interested on an input event, 46 // Enumerate additional data that one might be interested on an input event,
47 // which are usually wrapped in X valuators. If you modify any of this, 47 // which are usually wrapped in X valuators. If you modify any of this,
48 // make sure to update the kCachedAtoms data structure in the source file 48 // make sure to update the kCachedAtoms data structure in the source file
49 // and the k*Type[Start/End] constants used by IsCMTDataType and 49 // and the k*Type[Start/End] constants used by IsCMTDataType and
50 // IsTouchDataType. 50 // IsTouchDataType.
51 enum DataType { 51 enum DataType {
52 // Define the valuators used the CrOS CMT driver. Used by mice and CrOS 52 // Define the valuators used the CrOS CMT driver. Used by mice and CrOS
53 // touchpads. 53 // touchpads.
54 DT_CMT_SCROLL_X = 0, // Scroll amount on the X (horizontal) direction. 54 DT_CMT_SCROLL_X = 0, // Scroll amount on the X (horizontal) direction.
55 DT_CMT_SCROLL_Y, // Scroll amount on the Y (vertical) direction. 55 DT_CMT_SCROLL_Y, // Scroll amount on the Y (vertical) direction.
56 DT_CMT_ORDINAL_X, // Original (unaccelerated) value on the X direction. 56 DT_CMT_ORDINAL_X, // Original (unaccelerated) value on the X direction.
57 // Can be used both for scrolls and flings. 57 // Can be used both for scrolls and flings.
58 DT_CMT_ORDINAL_Y, // Original (unaccelerated) value on the Y direction. 58 DT_CMT_ORDINAL_Y, // Original (unaccelerated) value on the Y direction.
59 // Can be used both for scrolls and flings. 59 // Can be used both for scrolls and flings.
60 DT_CMT_START_TIME, // Gesture start time. 60 DT_CMT_START_TIME, // Gesture start time.
61 DT_CMT_END_TIME, // Gesture end time. 61 DT_CMT_END_TIME, // Gesture end time.
62 DT_CMT_FLING_X, // Fling amount on the X (horizontal) direction. 62 DT_CMT_FLING_X, // Fling amount on the X (horizontal) direction.
63 DT_CMT_FLING_Y, // Fling amount on the Y (vertical) direction. 63 DT_CMT_FLING_Y, // Fling amount on the Y (vertical) direction.
64 DT_CMT_FLING_STATE, // The state of fling gesture (whether the user just 64 DT_CMT_FLING_STATE, // The state of fling gesture (whether the user just
65 // start flinging or that he/she taps down). 65 // start flinging or that he/she taps down).
66 DT_CMT_METRICS_TYPE, // Metrics type of the metrics gesture, which are 66 DT_CMT_METRICS_TYPE, // Metrics type of the metrics gesture, which are
67 // used to wrap interesting patterns that we would 67 // used to wrap interesting patterns that we would
68 // like to track via the UMA system. 68 // like to track via the UMA system.
69 DT_CMT_METRICS_DATA1, // Complementary data 1 of the metrics gesture. 69 DT_CMT_METRICS_DATA1, // Complementary data 1 of the metrics gesture.
70 DT_CMT_METRICS_DATA2, // Complementary data 2 of the metrics gesture. 70 DT_CMT_METRICS_DATA2, // Complementary data 2 of the metrics gesture.
71 DT_CMT_FINGER_COUNT, // Finger counts in the current gesture. A same type 71 DT_CMT_FINGER_COUNT, // Finger counts in the current gesture. A same type
72 // of gesture can have very different meanings based 72 // of gesture can have very different meanings based
73 // on that (e.g. 2f scroll v.s. 3f swipe). 73 // on that (e.g. 2f scroll v.s. 3f swipe).
74 74
75 // End of CMT data types. 75 // End of CMT data types.
76 // Beginning of touch data types. 76 // Beginning of touch data types.
77 77
78 // Define the valuators following the Multi-touch Protocol. Used by 78 // Define the valuators following the Multi-touch Protocol. Used by
79 // touchscreen devices. 79 // touchscreen devices.
80 DT_TOUCH_MAJOR, // Length of the touch area. 80 DT_TOUCH_MAJOR, // Length of the touch area.
81 DT_TOUCH_MINOR, // Width of the touch area. 81 DT_TOUCH_MINOR, // Width of the touch area.
82 DT_TOUCH_ORIENTATION, // Angle between the X-axis and the major axis of the 82 DT_TOUCH_ORIENTATION, // Angle between the X-axis and the major axis of the
83 // touch area. 83 // touch area.
84 DT_TOUCH_PRESSURE, // Pressure of the touch contact. 84 DT_TOUCH_PRESSURE, // Pressure of the touch contact.
85 85
86 DT_TOUCH_POSITION_X, // Touch X position. 86 DT_TOUCH_POSITION_X, // Touch X position.
87 DT_TOUCH_POSITION_Y, // Touch Y position. 87 DT_TOUCH_POSITION_Y, // Touch Y position.
88 88
89 // NOTE for XInput MT: 'Tracking ID' is provided in every touch event to 89 // NOTE for XInput MT: 'Tracking ID' is provided in every touch event to
90 // track individual touch. 'Tracking ID' is an unsigned 32-bit value and 90 // track individual touch. 'Tracking ID' is an unsigned 32-bit value and
91 // is increased for each new touch. It will wrap back to 0 when reaching 91 // is increased for each new touch. It will wrap back to 0 when reaching
92 // the numerical limit. 92 // the numerical limit.
93 DT_TOUCH_TRACKING_ID, // ID of the touch point. 93 DT_TOUCH_TRACKING_ID, // ID of the touch point.
94 94
95 // Kernel timestamp from touch screen (if available). 95 // Kernel timestamp from touch screen (if available).
96 DT_TOUCH_RAW_TIMESTAMP, 96 DT_TOUCH_RAW_TIMESTAMP,
97 97
98 // End of touch data types. 98 // End of touch data types.
99 99
100 DT_LAST_ENTRY // This must come last. 100 DT_LAST_ENTRY // This must come last.
101 }; 101 };
102 102
103 // Data struct to store extracted data from an input event. 103 // Data struct to store extracted data from an input event.
104 typedef std::map<int, double> EventData; 104 typedef std::map<int, double> EventData;
105 105
106 static void CreateInstance(); 106 static void CreateInstance();
107 107
108 // We use int because enums can be casted to ints but not vice versa. 108 // We use int because enums can be casted to ints but not vice versa.
109 static bool IsCMTDataType(const int type); 109 static bool IsCMTDataType(const int type);
110 static bool IsTouchDataType(const int type); 110 static bool IsTouchDataType(const int type);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void SetDisabledKeyboardAllowedKeys( 231 void SetDisabledKeyboardAllowedKeys(
232 scoped_ptr<std::set<KeyboardCode> > excepted_keys); 232 scoped_ptr<std::set<KeyboardCode> > excepted_keys);
233 233
234 // Disables and enables events from devices by device id. 234 // Disables and enables events from devices by device id.
235 void DisableDevice(unsigned int deviceid); 235 void DisableDevice(unsigned int deviceid);
236 void EnableDevice(unsigned int deviceid); 236 void EnableDevice(unsigned int deviceid);
237 237
238 // Returns true if |native_event| should be blocked. 238 // Returns true if |native_event| should be blocked.
239 bool IsEventBlocked(const base::NativeEvent& native_event); 239 bool IsEventBlocked(const base::NativeEvent& native_event);
240 240
241 protected:
242 // DeviceHotplugEventObserver:
243 virtual void OnKeyboardDevicesUpdated(
244 const std::vector<KeyboardDevice>& devices) override;
245
241 private: 246 private:
242 DeviceDataManagerX11(); 247 DeviceDataManagerX11();
243 virtual ~DeviceDataManagerX11(); 248 virtual ~DeviceDataManagerX11();
244 249
250 // Returns whether the keyboard has been blocked.
251 static bool ShouldIgnoreKeyboard(const ui::KeyboardDevice keyboard,
252 DeviceDataManagerX11* manager);
253
245 // Initialize the XInput related system information. 254 // Initialize the XInput related system information.
246 bool InitializeXInputInternal(); 255 bool InitializeXInputInternal();
247 256
248 // Check if an XI event contains data of the specified type. 257 // Check if an XI event contains data of the specified type.
249 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; 258 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const;
250 259
251 void InitializeValuatorsForTest(int deviceid, 260 void InitializeValuatorsForTest(int deviceid,
252 int start_valuator, 261 int start_valuator,
253 int end_valuator, 262 int end_valuator,
254 double min_value, 263 double min_value,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 314
306 unsigned char button_map_[256]; 315 unsigned char button_map_[256];
307 int button_map_count_; 316 int button_map_count_;
308 317
309 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11); 318 DISALLOW_COPY_AND_ASSIGN(DeviceDataManagerX11);
310 }; 319 };
311 320
312 } // namespace ui 321 } // namespace ui
313 322
314 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_ 323 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_X11_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698