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_DEVICES_X11_DEVICE_LIST_CACHE_X11_H_ | 5 #ifndef UI_EVENTS_DEVICES_X11_DEVICE_LIST_CACHE_X11_H_ |
6 #define UI_EVENTS_DEVICES_X11_DEVICE_LIST_CACHE_X11_H_ | 6 #define UI_EVENTS_DEVICES_X11_DEVICE_LIST_CACHE_X11_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 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "ui/events/devices/events_devices_export.h" | 15 #include "ui/events/devices/x11/events_devices_x11_export.h" |
16 #include "ui/gfx/x/x11_types.h" | 16 #include "ui/gfx/x/x11_types.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 template <typename T> struct DefaultSingletonTraits; | 19 template <typename T> struct DefaultSingletonTraits; |
20 } | 20 } |
21 | 21 |
22 typedef struct _XDisplay Display; | 22 typedef struct _XDisplay Display; |
23 | 23 |
24 template <typename T, void (*D)(T*)> | 24 template <typename T, void (*D)(T*)> |
25 struct DeviceList { | 25 struct DeviceList { |
26 DeviceList() : count(0) {} | 26 DeviceList() : count(0) {} |
27 T& operator[](int x) { return devices[x]; } | 27 T& operator[](int x) { return devices[x]; } |
28 const T& operator[](int x) const { return devices[x]; } | 28 const T& operator[](int x) const { return devices[x]; } |
29 std::unique_ptr<T[], gfx::XObjectDeleter<T, void, D>> devices; | 29 std::unique_ptr<T[], gfx::XObjectDeleter<T, void, D>> devices; |
30 int count; | 30 int count; |
31 }; | 31 }; |
32 | 32 |
33 typedef struct DeviceList<XDeviceInfo, XFreeDeviceList> XDeviceList; | 33 typedef struct DeviceList<XDeviceInfo, XFreeDeviceList> XDeviceList; |
34 typedef struct DeviceList<XIDeviceInfo, XIFreeDeviceInfo> XIDeviceList; | 34 typedef struct DeviceList<XIDeviceInfo, XIFreeDeviceInfo> XIDeviceList; |
35 | 35 |
36 namespace ui { | 36 namespace ui { |
37 | 37 |
38 // A class to cache the current XInput device list. This minimized the | 38 // A class to cache the current XInput device list. This minimized the |
39 // round-trip time to the X server whenever such a device list is needed. The | 39 // round-trip time to the X server whenever such a device list is needed. The |
40 // update function will be called on each incoming XI_HierarchyChanged event. | 40 // update function will be called on each incoming XI_HierarchyChanged event. |
41 class EVENTS_DEVICES_EXPORT DeviceListCacheX11 { | 41 class EVENTS_DEVICES_X11_EXPORT DeviceListCacheX11 { |
42 public: | 42 public: |
43 static DeviceListCacheX11* GetInstance(); | 43 static DeviceListCacheX11* GetInstance(); |
44 | 44 |
45 void UpdateDeviceList(Display* display); | 45 void UpdateDeviceList(Display* display); |
46 | 46 |
47 // Returns the list of devices associated with |display|. Uses the old X11 | 47 // Returns the list of devices associated with |display|. Uses the old X11 |
48 // protocol to get the list of the devices. | 48 // protocol to get the list of the devices. |
49 const XDeviceList& GetXDeviceList(Display* display); | 49 const XDeviceList& GetXDeviceList(Display* display); |
50 | 50 |
51 // Returns the list of devices associated with |display|. Uses the newer | 51 // Returns the list of devices associated with |display|. Uses the newer |
(...skipping 11 matching lines...) Expand all Loading... |
63 XDeviceList x_dev_list_; | 63 XDeviceList x_dev_list_; |
64 XIDeviceList xi_dev_list_; | 64 XIDeviceList xi_dev_list_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX11); | 66 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX11); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace ui | 69 } // namespace ui |
70 | 70 |
71 #endif // UI_EVENTS_DEVICES_X11_DEVICE_LIST_CACHE_X11_H_ | 71 #endif // UI_EVENTS_DEVICES_X11_DEVICE_LIST_CACHE_X11_H_ |
72 | 72 |
OLD | NEW |