| 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 #include "ui/events/devices/x11/device_list_cache_x11.h" | 5 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "ui/events/devices/x11/device_data_manager_x11.h" | 11 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 DeviceListCacheX11::DeviceListCacheX11() { | 15 DeviceListCacheX11::DeviceListCacheX11() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 DeviceListCacheX11::~DeviceListCacheX11() { | 18 DeviceListCacheX11::~DeviceListCacheX11() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 DeviceListCacheX11* DeviceListCacheX11::GetInstance() { | 21 DeviceListCacheX11* DeviceListCacheX11::GetInstance() { |
| 22 return Singleton<DeviceListCacheX11>::get(); | 22 return base::Singleton<DeviceListCacheX11>::get(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void DeviceListCacheX11::UpdateDeviceList(Display* display) { | 25 void DeviceListCacheX11::UpdateDeviceList(Display* display) { |
| 26 XDeviceList& new_x_dev_list = x_dev_list_; | 26 XDeviceList& new_x_dev_list = x_dev_list_; |
| 27 new_x_dev_list.devices.reset( | 27 new_x_dev_list.devices.reset( |
| 28 XListInputDevices(display, &new_x_dev_list.count)); | 28 XListInputDevices(display, &new_x_dev_list.count)); |
| 29 | 29 |
| 30 xi_dev_list_.devices.reset(); | 30 xi_dev_list_.devices.reset(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 const XDeviceList& DeviceListCacheX11::GetXDeviceList(Display* display) { | 33 const XDeviceList& DeviceListCacheX11::GetXDeviceList(Display* display) { |
| 34 XDeviceList& x_dev_list = x_dev_list_; | 34 XDeviceList& x_dev_list = x_dev_list_; |
| 35 // Note that the function can be called before any update has taken place. | 35 // Note that the function can be called before any update has taken place. |
| 36 if (!x_dev_list.devices && !x_dev_list.count) | 36 if (!x_dev_list.devices && !x_dev_list.count) |
| 37 x_dev_list.devices.reset(XListInputDevices(display, &x_dev_list.count)); | 37 x_dev_list.devices.reset(XListInputDevices(display, &x_dev_list.count)); |
| 38 return x_dev_list; | 38 return x_dev_list; |
| 39 } | 39 } |
| 40 | 40 |
| 41 const XIDeviceList& DeviceListCacheX11::GetXI2DeviceList(Display* display) { | 41 const XIDeviceList& DeviceListCacheX11::GetXI2DeviceList(Display* display) { |
| 42 XIDeviceList& xi_dev_list = xi_dev_list_; | 42 XIDeviceList& xi_dev_list = xi_dev_list_; |
| 43 if (!xi_dev_list.devices && !xi_dev_list.count) { | 43 if (!xi_dev_list.devices && !xi_dev_list.count) { |
| 44 xi_dev_list.devices.reset( | 44 xi_dev_list.devices.reset( |
| 45 XIQueryDevice(display, XIAllDevices, &xi_dev_list.count)); | 45 XIQueryDevice(display, XIAllDevices, &xi_dev_list.count)); |
| 46 } | 46 } |
| 47 return xi_dev_list; | 47 return xi_dev_list; |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace ui | 50 } // namespace ui |
| 51 | 51 |
| OLD | NEW |