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

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

Issue 280833002: Re-land "Issue 191223007: Move touch CTM from X into Chrome" (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adding missing file again Created 6 years, 7 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
« no previous file with comments | « ui/events/test/events_test_utils_x11.cc ('k') | ui/events/x/device_data_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_H_ 5 #ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ 6 #define UI_EVENTS_X_DEVICE_DATA_MANAGER_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.
11 #ifndef Bool 11 #ifndef Bool
12 #define Bool int 12 #define Bool int
13 #endif 13 #endif
14 14
15 #include <X11/extensions/XInput2.h> 15 #include <X11/extensions/XInput2.h>
16 16
17 #include <bitset> 17 #include <bitset>
18 #include <map> 18 #include <map>
19 #include <vector> 19 #include <vector>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/event_types.h" 22 #include "base/event_types.h"
23 #include "base/memory/scoped_ptr.h"
24 #include "ui/events/event.h"
23 #include "ui/events/event_constants.h" 25 #include "ui/events/event_constants.h"
24 #include "ui/events/events_base_export.h" 26 #include "ui/events/events_base_export.h"
27 #include "ui/gfx/geometry/rect.h"
28 #include "ui/gfx/transform.h"
25 #include "ui/gfx/x/x11_atom_cache.h" 29 #include "ui/gfx/x/x11_atom_cache.h"
26 30
27 template <typename T> struct DefaultSingletonTraits; 31 template <typename T> struct DefaultSingletonTraits;
28 32
29 typedef union _XEvent XEvent; 33 typedef union _XEvent XEvent;
30 34
31 namespace ui { 35 namespace ui {
32 36
33 // CrOS touchpad metrics gesture types 37 // CrOS touchpad metrics gesture types
34 enum GestureMetricsType { 38 enum GestureMetricsType {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // This function is only for test purpose. It does not query the X server for 214 // This function is only for test purpose. It does not query the X server for
211 // the actual device info, but rather inits the relevant valuator structures 215 // the actual device info, but rather inits the relevant valuator structures
212 // to have safe default values for testing. 216 // to have safe default values for testing.
213 void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen, 217 void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen,
214 const std::vector<unsigned int>& cmt_devices); 218 const std::vector<unsigned int>& cmt_devices);
215 219
216 void SetValuatorDataForTest(XIDeviceEvent* xievent, 220 void SetValuatorDataForTest(XIDeviceEvent* xievent,
217 DataType type, 221 DataType type,
218 double value); 222 double value);
219 223
224 void ClearTouchTransformerRecord();
225 void UpdateTouchInfoForDisplay(int64 display_id,
226 int touch_device_id,
227 const gfx::Transform& touch_transformer);
228 void ApplyTouchTransformer(int touch_device_id, float* x, float* y);
229 int64 GetDisplayForTouchDevice(int touch_device_id) const;
230 bool TouchEventNeedsCalibrate(int touch_device_id) const;
231
220 private: 232 private:
221 // Requirement for Singleton. 233 // Requirement for Singleton.
222 friend struct DefaultSingletonTraits<DeviceDataManager>; 234 friend struct DefaultSingletonTraits<DeviceDataManager>;
223 235
224 DeviceDataManager(); 236 DeviceDataManager();
225 ~DeviceDataManager(); 237 ~DeviceDataManager();
226 238
227 // Initialize the XInput related system information. 239 // Initialize the XInput related system information.
228 bool InitializeXInputInternal(); 240 bool InitializeXInputInternal();
229 241
230 // Check if an XI event contains data of the specified type. 242 // Check if an XI event contains data of the specified type.
231 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const; 243 bool HasEventData(const XIDeviceEvent* xiev, const DataType type) const;
232 244
233 void InitializeValuatorsForTest(int deviceid, 245 void InitializeValuatorsForTest(int deviceid,
234 int start_valuator, 246 int start_valuator,
235 int end_valuator, 247 int end_valuator,
236 double min_value, 248 double min_value,
237 double max_value); 249 double max_value);
238 250
251 bool IsTouchDeviceIdValid(int touch_device_id) const;
252
239 static const int kMaxDeviceNum = 128; 253 static const int kMaxDeviceNum = 128;
240 static const int kMaxXIEventType = XI_LASTEVENT + 1; 254 static const int kMaxXIEventType = XI_LASTEVENT + 1;
241 static const int kMaxSlotNum = 10; 255 static const int kMaxSlotNum = 10;
242 256
243 // Major opcode for the XInput extension. Used to identify XInput events. 257 // Major opcode for the XInput extension. Used to identify XInput events.
244 int xi_opcode_; 258 int xi_opcode_;
245 259
246 // A quick lookup table for determining if the XI event is an XIDeviceEvent. 260 // A quick lookup table for determining if the XI event is an XIDeviceEvent.
247 std::bitset<kMaxXIEventType> xi_device_event_types_; 261 std::bitset<kMaxXIEventType> xi_device_event_types_;
248 262
(...skipping 26 matching lines...) Expand all
275 // doesn't think X/device doesn't know about the valuators. We currently 289 // doesn't think X/device doesn't know about the valuators. We currently
276 // use this only on touchscreen devices. 290 // use this only on touchscreen devices.
277 std::vector<double> last_seen_valuator_[kMaxDeviceNum][kMaxSlotNum]; 291 std::vector<double> last_seen_valuator_[kMaxDeviceNum][kMaxSlotNum];
278 292
279 // X11 atoms cache. 293 // X11 atoms cache.
280 X11AtomCache atom_cache_; 294 X11AtomCache atom_cache_;
281 295
282 unsigned char button_map_[256]; 296 unsigned char button_map_[256];
283 int button_map_count_; 297 int button_map_count_;
284 298
299 // Table to keep track of which display id is mapped to which touch device.
300 int64 touch_device_to_display_map_[kMaxDeviceNum];
301 // Index table to find the TouchTransformer for a touch device.
302 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum];
303
285 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); 304 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager);
286 }; 305 };
287 306
288 } // namespace ui 307 } // namespace ui
289 308
290 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ 309 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/events/test/events_test_utils_x11.cc ('k') | ui/events/x/device_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698