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

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

Issue 313913004: Block internal PlatformEvents before they are dispatched in touchview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Block events from disabled devices through DeviceDataManager. Created 6 years, 6 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 | Annotate | Revision Log
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 <set>
19 #include <vector> 20 #include <vector>
20 21
21 #include "base/basictypes.h" 22 #include "base/basictypes.h"
22 #include "base/event_types.h" 23 #include "base/event_types.h"
23 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
24 #include "ui/events/event.h" 25 #include "ui/events/event.h"
25 #include "ui/events/event_constants.h" 26 #include "ui/events/event_constants.h"
26 #include "ui/events/events_base_export.h" 27 #include "ui/events/events_base_export.h"
27 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
28 #include "ui/gfx/transform.h" 29 #include "ui/gfx/transform.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 double value); 223 double value);
223 224
224 void ClearTouchTransformerRecord(); 225 void ClearTouchTransformerRecord();
225 void UpdateTouchInfoForDisplay(int64 display_id, 226 void UpdateTouchInfoForDisplay(int64 display_id,
226 int touch_device_id, 227 int touch_device_id,
227 const gfx::Transform& touch_transformer); 228 const gfx::Transform& touch_transformer);
228 void ApplyTouchTransformer(int touch_device_id, float* x, float* y); 229 void ApplyTouchTransformer(int touch_device_id, float* x, float* y);
229 int64 GetDisplayForTouchDevice(int touch_device_id) const; 230 int64 GetDisplayForTouchDevice(int touch_device_id) const;
230 bool TouchEventNeedsCalibrate(int touch_device_id) const; 231 bool TouchEventNeedsCalibrate(int touch_device_id) const;
231 232
233 // Disables the physical keyboard except for the |excepted_keys| provided.
234 void DisableKeyboard(scoped_ptr<std::set<KeyboardCode> > excepted_keys);
235 // Re-enables the keyboard after a previous call to DisableKeyboard.
236 void EnableKeyboard();
237
238 // Disables and enables events from devices by device id.
239 void DisableDevice(unsigned int deviceid);
240 void EnableDevice(unsigned int deviceid);
241
242 // Returns true if the passed in event should be blocked. For mouse events
243 // this also has the side effect of returning the mouse cursor to the last
244 // known location from an unblocked event.
sadrul 2014/06/12 21:02:27 Can you clarify the comment about mouse events? (c
flackr 2014/06/18 05:28:32 Done.
245 bool EventBlocked(const base::NativeEvent& native_event);
sadrul 2014/06/12 21:02:27 IsEventBlocked()?
flackr 2014/06/18 05:28:32 Done.
246
232 private: 247 private:
233 // Requirement for Singleton. 248 // Requirement for Singleton.
234 friend struct DefaultSingletonTraits<DeviceDataManager>; 249 friend struct DefaultSingletonTraits<DeviceDataManager>;
235 250
236 DeviceDataManager(); 251 DeviceDataManager();
237 ~DeviceDataManager(); 252 ~DeviceDataManager();
238 253
239 // Initialize the XInput related system information. 254 // Initialize the XInput related system information.
240 bool InitializeXInputInternal(); 255 bool InitializeXInputInternal();
241 256
(...skipping 16 matching lines...) Expand all
258 int xi_opcode_; 273 int xi_opcode_;
259 274
260 // A quick lookup table for determining if the XI event is an XIDeviceEvent. 275 // A quick lookup table for determining if the XI event is an XIDeviceEvent.
261 std::bitset<kMaxXIEventType> xi_device_event_types_; 276 std::bitset<kMaxXIEventType> xi_device_event_types_;
262 277
263 // A quick lookup table for determining if events from the pointer device 278 // A quick lookup table for determining if events from the pointer device
264 // should be processed. 279 // should be processed.
265 std::bitset<kMaxDeviceNum> cmt_devices_; 280 std::bitset<kMaxDeviceNum> cmt_devices_;
266 std::bitset<kMaxDeviceNum> touchpads_; 281 std::bitset<kMaxDeviceNum> touchpads_;
267 282
283 // A quick lookup table for determining if events from the XI device
284 // be blocked.
sadrul 2014/06/12 21:02:27 +should
flackr 2014/06/18 05:28:32 Done.
285 std::bitset<kMaxDeviceNum> blocked_devices_;
286
287 // When true, keyboard events will be blocked.
288 // TODO(flackr): Only block the internal keyboard when XI2 is used for key
289 // events. http://crbug.com/362881.
290 bool blocked_keyboard_;
291
292 // The set of keys allowed while the keyboard is blocked.
293 scoped_ptr<std::set<KeyboardCode> > blocked_keyboard_allowed_keys_;
294
268 // Number of valuators on the specific device. 295 // Number of valuators on the specific device.
269 int valuator_count_[kMaxDeviceNum]; 296 int valuator_count_[kMaxDeviceNum];
270 297
271 // Index table to find the valuator for DataType on the specific device 298 // Index table to find the valuator for DataType on the specific device
272 // by valuator_lookup_[device_id][data_type]. 299 // by valuator_lookup_[device_id][data_type].
273 std::vector<int> valuator_lookup_[kMaxDeviceNum]; 300 std::vector<int> valuator_lookup_[kMaxDeviceNum];
274 301
275 // Index table to find the DataType for valuator on the specific device 302 // Index table to find the DataType for valuator on the specific device
276 // by data_type_lookup_[device_id][valuator]. 303 // by data_type_lookup_[device_id][valuator].
277 std::vector<int> data_type_lookup_[kMaxDeviceNum]; 304 std::vector<int> data_type_lookup_[kMaxDeviceNum];
(...skipping 22 matching lines...) Expand all
300 int64 touch_device_to_display_map_[kMaxDeviceNum]; 327 int64 touch_device_to_display_map_[kMaxDeviceNum];
301 // Index table to find the TouchTransformer for a touch device. 328 // Index table to find the TouchTransformer for a touch device.
302 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; 329 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum];
303 330
304 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); 331 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager);
305 }; 332 };
306 333
307 } // namespace ui 334 } // namespace ui
308 335
309 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_ 336 #endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698