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 |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "ui/events/events_base_export.h" | 14 #include "ui/events/events_base_export.h" |
15 | 15 |
16 template <typename T> struct DefaultSingletonTraits; | 16 template <typename T> struct DefaultSingletonTraits; |
17 | 17 |
18 typedef struct _XDisplay Display; | 18 typedef struct _XDisplay Display; |
19 | 19 |
20 template <typename T> | 20 template <typename T> |
21 struct DeviceList { | 21 struct DeviceList { |
22 DeviceList() : devices(NULL), count(0) { | 22 DeviceList() : devices(NULL), count(0) { |
23 } | 23 } |
24 T& operator[] (int x) { | 24 T& operator[] (int x) { |
25 return devices[x]; | 25 return devices[x]; |
26 } | 26 } |
| 27 const T& operator[](int x) const { return devices[x]; } |
27 T* devices; | 28 T* devices; |
28 int count; | 29 int count; |
29 }; | 30 }; |
30 | 31 |
31 typedef struct DeviceList<XDeviceInfo> XDeviceList; | 32 typedef struct DeviceList<XDeviceInfo> XDeviceList; |
32 typedef struct DeviceList<XIDeviceInfo> XIDeviceList; | 33 typedef struct DeviceList<XIDeviceInfo> XIDeviceList; |
33 | 34 |
34 namespace ui { | 35 namespace ui { |
35 | 36 |
36 // A class to cache the current XInput device list. This minimized the | 37 // A class to cache the current XInput device list. This minimized the |
(...skipping 24 matching lines...) Expand all Loading... |
61 std::map<Display*, XDeviceList> x_dev_list_map_; | 62 std::map<Display*, XDeviceList> x_dev_list_map_; |
62 std::map<Display*, XIDeviceList> xi_dev_list_map_; | 63 std::map<Display*, XIDeviceList> xi_dev_list_map_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX); | 65 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace ui | 68 } // namespace ui |
68 | 69 |
69 #endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ | 70 #endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_ |
70 | 71 |
OLD | NEW |