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

Side by Side Diff: ui/events/devices/x11/touch_factory_x11.h

Issue 1071193002: Change device IDs from unsigned to signed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check for negative IDs Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DEVICES_X11_TOUCH_FACTORY_X11_H_ 5 #ifndef UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_
6 #define UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ 6 #define UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_
7 7
8 #include <bitset> 8 #include <bitset>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Checks whether an XI2 event should be processed or not (i.e. if the event 42 // Checks whether an XI2 event should be processed or not (i.e. if the event
43 // originated from a device we are interested in). 43 // originated from a device we are interested in).
44 bool ShouldProcessXI2Event(XEvent* xevent); 44 bool ShouldProcessXI2Event(XEvent* xevent);
45 45
46 // Setup an X Window for XInput2 events. 46 // Setup an X Window for XInput2 events.
47 void SetupXI2ForXWindow(::Window xid); 47 void SetupXI2ForXWindow(::Window xid);
48 48
49 // Keeps a list of touch devices so that it is possible to determine if a 49 // Keeps a list of touch devices so that it is possible to determine if a
50 // pointer event is a touch-event or a mouse-event. The list is reset each 50 // pointer event is a touch-event or a mouse-event. The list is reset each
51 // time this is called. 51 // time this is called.
52 void SetTouchDeviceList(const std::vector<unsigned int>& devices); 52 void SetTouchDeviceList(const std::vector<int>& devices);
53
54 // Is the device ID valid?
55 bool IsValidDevice(int deviceid) const;
53 56
54 // Is the device a touch-device? 57 // Is the device a touch-device?
55 bool IsTouchDevice(unsigned int deviceid) const; 58 bool IsTouchDevice(int deviceid) const;
56 59
57 // Is the device a real multi-touch-device? (see doc. for |touch_device_list_| 60 // Is the device a real multi-touch-device? (see doc. for |touch_device_list_|
58 // below for more explanation.) 61 // below for more explanation.)
59 bool IsMultiTouchDevice(unsigned int deviceid) const; 62 bool IsMultiTouchDevice(int deviceid) const;
60 63
61 // Tries to find an existing slot ID mapping to tracking ID. Returns true 64 // Tries to find an existing slot ID mapping to tracking ID. Returns true
62 // if the slot is found and it is saved in |slot|, false if no such slot 65 // if the slot is found and it is saved in |slot|, false if no such slot
63 // can be found. 66 // can be found.
64 bool QuerySlotForTrackingID(uint32 tracking_id, int* slot); 67 bool QuerySlotForTrackingID(uint32 tracking_id, int* slot);
65 68
66 // Tries to find an existing slot ID mapping to tracking ID. If there 69 // Tries to find an existing slot ID mapping to tracking ID. If there
67 // isn't one already, allocates a new slot ID and sets up the mapping. 70 // isn't one already, allocates a new slot ID and sets up the mapping.
68 int GetSlotForTrackingID(uint32 tracking_id); 71 int GetSlotForTrackingID(uint32 tracking_id);
69 72
70 // Releases the slot ID mapping to tracking ID. 73 // Releases the slot ID mapping to tracking ID.
71 void ReleaseSlotForTrackingID(uint32 tracking_id); 74 void ReleaseSlotForTrackingID(uint32 tracking_id);
72 75
73 // Whether any touch device is currently present and enabled. 76 // Whether any touch device is currently present and enabled.
74 bool IsTouchDevicePresent(); 77 bool IsTouchDevicePresent();
75 78
76 // Pairs of <vendor id, product id> of external touch screens. 79 // Pairs of <vendor id, product id> of external touch screens.
77 const std::set<std::pair<int, int> >& GetTouchscreenIds() const { 80 const std::set<std::pair<int, int> >& GetTouchscreenIds() const {
78 return touchscreen_ids_; 81 return touchscreen_ids_;
79 } 82 }
80 83
81 // Resets the TouchFactory singleton. 84 // Resets the TouchFactory singleton.
82 void ResetForTest(); 85 void ResetForTest();
83 86
84 // Sets up the device id in the list |devices| as multi-touch capable 87 // Sets up the device id in the list |devices| as multi-touch capable
85 // devices and enables touch events processing. This function is only 88 // devices and enables touch events processing. This function is only
86 // for test purpose, and it does not query from X server. 89 // for test purpose, and it does not query from X server.
87 void SetTouchDeviceForTest(const std::vector<unsigned int>& devices); 90 void SetTouchDeviceForTest(const std::vector<int>& devices);
88 91
89 // Sets up the device id in the list |devices| as pointer devices. 92 // Sets up the device id in the list |devices| as pointer devices.
90 // This function is only for test purpose, and it does not query from 93 // This function is only for test purpose, and it does not query from
91 // X server. 94 // X server.
92 void SetPointerDeviceForTest(const std::vector<unsigned int>& devices); 95 void SetPointerDeviceForTest(const std::vector<int>& devices);
93 96
94 private: 97 private:
95 // Requirement for Singleton 98 // Requirement for Singleton
96 friend struct DefaultSingletonTraits<TouchFactory>; 99 friend struct DefaultSingletonTraits<TouchFactory>;
97 100
98 void CacheTouchscreenIds(Display* display, int id); 101 void CacheTouchscreenIds(Display* display, int id);
99 102
100 // NOTE: To keep track of touch devices, we currently maintain a lookup table 103 // NOTE: To keep track of touch devices, we currently maintain a lookup table
101 // to quickly decide if a device is a touch device or not. We also maintain a 104 // to quickly decide if a device is a touch device or not. We also maintain a
102 // list of the touch devices. Ideally, there will be only one touch device, 105 // list of the touch devices. Ideally, there will be only one touch device,
(...skipping 27 matching lines...) Expand all
130 int virtual_core_keyboard_device_; 133 int virtual_core_keyboard_device_;
131 134
132 SequentialIDGenerator id_generator_; 135 SequentialIDGenerator id_generator_;
133 136
134 DISALLOW_COPY_AND_ASSIGN(TouchFactory); 137 DISALLOW_COPY_AND_ASSIGN(TouchFactory);
135 }; 138 };
136 139
137 } // namespace ui 140 } // namespace ui
138 141
139 #endif // UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_ 142 #endif // UI_EVENTS_DEVICES_X11_TOUCH_FACTORY_X11_H_
OLDNEW
« no previous file with comments | « ui/events/devices/x11/device_data_manager_x11_unittest.cc ('k') | ui/events/devices/x11/touch_factory_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698