OLD | NEW |
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_X_DEVICE_LIST_CACHE_X_H_ | 5 #ifndef UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ |
6 #define UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ | 6 #define UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ |
7 | 7 |
8 #include <X11/extensions/XInput.h> | 8 #include <X11/extensions/XInput.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // A class to cache the current XInput device list. This minimized the | 36 // A class to cache the current XInput device list. This minimized the |
37 // round-trip time to the X server whenever such a device list is needed. The | 37 // round-trip time to the X server whenever such a device list is needed. The |
38 // update function will be called on each incoming XI_HierarchyChanged event. | 38 // update function will be called on each incoming XI_HierarchyChanged event. |
39 class EVENTS_EXPORT DeviceListCacheX { | 39 class EVENTS_EXPORT DeviceListCacheX { |
40 public: | 40 public: |
41 static DeviceListCacheX* GetInstance(); | 41 static DeviceListCacheX* GetInstance(); |
42 | 42 |
43 void UpdateDeviceList(Display* display); | 43 void UpdateDeviceList(Display* display); |
44 | 44 |
45 // Returns the list of devices associated with |display|. Uses the old X11 | |
46 // protocol to get the list of the devices. | |
47 const XDeviceList& GetXDeviceList(Display* display); | 45 const XDeviceList& GetXDeviceList(Display* display); |
48 | |
49 // Returns the list of devices associated with |display|. Uses the newer | |
50 // XINPUT2 protocol to get the list of devices. Before making this call, make | |
51 // sure that XInput2 support is available (e.g. by calling | |
52 // IsXInput2Available()). | |
53 const XIDeviceList& GetXI2DeviceList(Display* display); | 46 const XIDeviceList& GetXI2DeviceList(Display* display); |
54 | 47 |
55 private: | 48 private: |
56 friend struct DefaultSingletonTraits<DeviceListCacheX>; | 49 friend struct DefaultSingletonTraits<DeviceListCacheX>; |
57 | 50 |
58 DeviceListCacheX(); | 51 DeviceListCacheX(); |
59 ~DeviceListCacheX(); | 52 ~DeviceListCacheX(); |
60 | 53 |
61 std::map<Display*, XDeviceList> x_dev_list_map_; | 54 std::map<Display*, XDeviceList> x_dev_list_map_; |
62 std::map<Display*, XIDeviceList> xi_dev_list_map_; | 55 std::map<Display*, XIDeviceList> xi_dev_list_map_; |
63 | 56 |
| 57 bool xi2_; |
| 58 |
64 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX); | 59 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX); |
65 }; | 60 }; |
66 | 61 |
67 } // namespace ui | 62 } // namespace ui |
68 | 63 |
69 #endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ | 64 #endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ |
70 | 65 |
OLD | NEW |