OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_TOUCH_TOUCH_FACTORY_H_ | 5 #ifndef UI_BASE_TOUCH_TOUCH_FACTORY_H_ |
6 #define UI_BASE_TOUCH_TOUCH_FACTORY_H_ | 6 #define UI_BASE_TOUCH_TOUCH_FACTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <bitset> | 9 #include <bitset> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/hash_tables.h" |
13 #include "base/timer.h" | 14 #include "base/timer.h" |
14 #include "ui/base/ui_export.h" | 15 #include "ui/base/ui_export.h" |
15 | 16 |
16 typedef unsigned long Cursor; | 17 typedef unsigned long Cursor; |
17 typedef unsigned long Window; | 18 typedef unsigned long Window; |
18 typedef struct _XDisplay Display; | 19 typedef struct _XDisplay Display; |
19 typedef union _XEvent XEvent; | 20 typedef union _XEvent XEvent; |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 | 23 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void SetupXI2ForXWindow(::Window xid); | 71 void SetupXI2ForXWindow(::Window xid); |
71 | 72 |
72 // Keeps a list of touch devices so that it is possible to determine if a | 73 // Keeps a list of touch devices so that it is possible to determine if a |
73 // pointer event is a touch-event or a mouse-event. The list is reset each | 74 // pointer event is a touch-event or a mouse-event. The list is reset each |
74 // time this is called. | 75 // time this is called. |
75 void SetTouchDeviceList(const std::vector<unsigned int>& devices); | 76 void SetTouchDeviceList(const std::vector<unsigned int>& devices); |
76 | 77 |
77 // Is the device a touch-device? | 78 // Is the device a touch-device? |
78 bool IsTouchDevice(unsigned int deviceid) const; | 79 bool IsTouchDevice(unsigned int deviceid) const; |
79 | 80 |
80 #if !defined(USE_XI2_MT) | 81 #if defined(USE_XI2_MT) |
| 82 // Tries to find an existing slot ID mapping to tracking ID. If there |
| 83 // isn't one already, allocates a new slot ID and sets up the mapping. |
| 84 int GetSlotForTrackingID(uint32 tracking_id); |
| 85 |
| 86 // Releases the slot ID mapping to tracking ID. |
| 87 void ReleaseSlotForTrackingID(uint32 tracking_id); |
| 88 #endif |
| 89 |
81 // Is the slot ID currently used? | 90 // Is the slot ID currently used? |
82 bool IsSlotUsed(int slot) const; | 91 bool IsSlotUsed(int slot) const; |
83 | 92 |
84 // Marks a slot as being used/unused. | 93 // Marks a slot as being used/unused. |
85 void SetSlotUsed(int slot, bool used); | 94 void SetSlotUsed(int slot, bool used); |
86 #endif | |
87 | 95 |
88 // Grabs the touch devices for the specified window on the specified display. | 96 // Grabs the touch devices for the specified window on the specified display. |
89 // Returns if grab was successful for all touch devices. | 97 // Returns if grab was successful for all touch devices. |
90 bool GrabTouchDevices(Display* display, ::Window window); | 98 bool GrabTouchDevices(Display* display, ::Window window); |
91 | 99 |
92 // Ungrabs the touch devices. Returns if ungrab was successful for all touch | 100 // Ungrabs the touch devices. Returns if ungrab was successful for all touch |
93 // devices. | 101 // devices. |
94 bool UngrabTouchDevices(Display* display); | 102 bool UngrabTouchDevices(Display* display); |
95 | 103 |
96 // Updates the root window to show (or hide) the cursor. Also indicate whether | 104 // Updates the root window to show (or hide) the cursor. Also indicate whether |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // index at the expense of space. If the kMaxDeviceNum grows larger that the | 191 // index at the expense of space. If the kMaxDeviceNum grows larger that the |
184 // space waste becomes a concern, the 2D lookup table can be replaced by a | 192 // space waste becomes a concern, the 2D lookup table can be replaced by a |
185 // hash map. | 193 // hash map. |
186 signed char valuator_lookup_[kMaxDeviceNum][TP_LAST_ENTRY]; | 194 signed char valuator_lookup_[kMaxDeviceNum][TP_LAST_ENTRY]; |
187 | 195 |
188 // Index table to find the min & max value of the TouchParam on a specific | 196 // Index table to find the min & max value of the TouchParam on a specific |
189 // device. | 197 // device. |
190 int touch_param_min_[kMaxDeviceNum][TP_LAST_ENTRY]; | 198 int touch_param_min_[kMaxDeviceNum][TP_LAST_ENTRY]; |
191 int touch_param_max_[kMaxDeviceNum][TP_LAST_ENTRY]; | 199 int touch_param_max_[kMaxDeviceNum][TP_LAST_ENTRY]; |
192 | 200 |
193 #if !defined(USE_XI2_MT) | |
194 // Maximum simultaneous touch points. | 201 // Maximum simultaneous touch points. |
195 static const int kMaxTouchPoints = 32; | 202 static const int kMaxTouchPoints = 32; |
196 | 203 |
| 204 #if defined(USE_XI2_MT) |
| 205 // Stores the minimum available slot ID which helps get slot ID from |
| 206 // tracking ID. When it equals to kMaxTouchPoints, there is no available |
| 207 // slot. |
| 208 int min_available_slot_; |
| 209 #endif |
| 210 |
197 // A lookup table for slots in use for a touch event. | 211 // A lookup table for slots in use for a touch event. |
198 std::bitset<kMaxTouchPoints> slots_used_; | 212 std::bitset<kMaxTouchPoints> slots_used_; |
| 213 |
| 214 #if defined(USE_XI2_MT) |
| 215 // A hash table to map tracking ID to slot. |
| 216 typedef base::hash_map<uint32, int> TrackingIdMap; |
| 217 TrackingIdMap tracking_id_map_; |
199 #endif | 218 #endif |
200 | |
201 DISALLOW_COPY_AND_ASSIGN(TouchFactory); | 219 DISALLOW_COPY_AND_ASSIGN(TouchFactory); |
202 }; | 220 }; |
203 | 221 |
204 } // namespace ui | 222 } // namespace ui |
205 | 223 |
206 #endif // UI_BASE_TOUCH_TOUCH_FACTORY_H_ | 224 #endif // UI_BASE_TOUCH_TOUCH_FACTORY_H_ |
OLD | NEW |