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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_
6 #define UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_
8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h>
13 #include "base/basictypes.h"
14 #include "ui/events/events_export.h"
16 template <typename T> struct DefaultSingletonTraits;
18 typedef struct _XDisplay Display;
22 DeviceList() : devices(NULL), count(0) {
24 T& operator[] (int x) {
31 typedef struct DeviceList<XDeviceInfo> XDeviceList;
32 typedef struct DeviceList<XIDeviceInfo> XIDeviceList;
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
38 // update function will be called on each incoming XI_HierarchyChanged event.
39 class EVENTS_EXPORT DeviceListCacheX {
41 static DeviceListCacheX* GetInstance();
43 void UpdateDeviceList(Display* display);
45 const XDeviceList& GetXDeviceList(Display* display);
46 const XIDeviceList& GetXI2DeviceList(Display* display);
49 friend struct DefaultSingletonTraits<DeviceListCacheX>;
54 std::map<Display*, XDeviceList> x_dev_list_map_;
55 std::map<Display*, XIDeviceList> xi_dev_list_map_;
59 DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX);
64 #endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_