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

Side by Side Diff: views/touchui/touch_factory.h

Issue 7927001: touchui: Convert XI2 MT tracking id to slot id for gesture recognizer (Closed) Base URL: nhu@powerbuilder.sh.intel.com:/home/www-data/git-repos/chromium/chromium.git@trunk
Patch Set: Update the patch set according to comment #2. Created 9 years, 3 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) 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 VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 5 #ifndef VIEWS_TOUCHUI_TOUCH_FACTORY_H_
6 #define VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 6 #define VIEWS_TOUCHUI_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 "views/views_export.h" 15 #include "views/views_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 views { 22 namespace views {
22 23
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
197 // A lookup table for slots in use for a touch event. 204 // A lookup table for slots in use for a touch event.
198 std::bitset<kMaxTouchPoints> slots_used_; 205 std::bitset<kMaxTouchPoints> slots_used_;
206
207 #if defined(USE_XI2_MT)
208 // A hash table to map tracking ID to slot.
209 typedef base::hash_map<uint32, int> TrackingIdMap;
210 TrackingIdMap tracking_id_map_;
199 #endif 211 #endif
200
201 DISALLOW_COPY_AND_ASSIGN(TouchFactory); 212 DISALLOW_COPY_AND_ASSIGN(TouchFactory);
202 }; 213 };
203 214
204 } // namespace views 215 } // namespace views
205 216
206 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 217 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698