OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef VIEWS_TOUCHUI_TOUCH_FACTORY_H_ | |
6 #define VIEWS_TOUCHUI_TOUCH_FACTORY_H_ | |
7 #pragma once | |
8 | |
9 #include <bitset> | |
10 #include <vector> | |
11 | |
12 #include "base/singleton.h" | |
13 | |
14 typedef unsigned long Window; | |
15 typedef struct _XDisplay Display; | |
16 | |
17 namespace views { | |
18 | |
19 // Functions related to determining touch devices. | |
20 class TouchFactory { | |
21 public: | |
22 // Returns the TouchFactory singleton. | |
23 static TouchFactory* GetInstance(); | |
24 | |
25 // Keep a list of touch devices so that it is possible to determine if a | |
26 // pointer event is a touch-event or a mouse-event. The list is reset each | |
27 // time this is called. | |
28 void SetTouchDeviceList(const std::vector<unsigned int>& devices); | |
29 | |
30 // Is the device a touch-device? | |
31 bool IsTouchDevice(unsigned int deviceid); | |
32 | |
33 // Grab the touch devices for the specified window on the specified display. | |
34 // Returns if grab was successful for all touch devices. | |
35 bool GrabTouchDevices(Display* display, ::Window window); | |
36 | |
37 // Ungrab the touch devices. Returns if ungrab was successful for all touch | |
38 // devices. | |
39 bool UngrabTouchDevices(Display* display); | |
40 | |
41 private: | |
42 TouchFactory(); | |
43 | |
44 // Requirement for Signleton | |
45 friend struct DefaultSingletonTraits<TouchFactory>; | |
46 | |
47 // NOTE: To keep track of touch devices, we currently maintain a lookup table | |
48 // to quickly decide if a device is a touch device or not. We also maintain a | |
49 // list of the touch devices. Ideally, there will be only one touch device, | |
50 // and instead of having the lookup table and the list, there will be a single | |
51 // identifier for the touch device. This can be completed after enough testing | |
52 // on real touch devices. | |
53 | |
54 // A quick lookup table for determining if a device is a touch device. | |
55 std::bitset<128> touch_device_lookup_; | |
56 | |
57 // The list of touch devices. | |
58 std::vector<int> touch_device_list_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TouchFactory); | |
61 }; | |
62 | |
63 } // namespace views | |
64 | |
65 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_ | |
OLD | NEW |