Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: ui/events/devices/x11/device_list_cache_x11.cc

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "ui/events/devices/x11/device_list_cache_x11.h"
6
7 #include <algorithm>
8
9 #include "base/memory/singleton.h"
10 #include "base/message_loop/message_loop.h"
11 #include "ui/events/devices/x11/device_data_manager_x11.h"
12
13 namespace {
14
15 bool IsXI2Available() {
16 #if defined(USE_AURA)
17 return ui::DeviceDataManagerX11::GetInstance()->IsXInput2Available();
18 #else
19 return false;
20 #endif
21 }
22
23 }
24
25 namespace ui {
26
27 DeviceListCacheX11::DeviceListCacheX11() {
28 }
29
30 DeviceListCacheX11::~DeviceListCacheX11() {
31 }
32
33 DeviceListCacheX11* DeviceListCacheX11::GetInstance() {
34 return Singleton<DeviceListCacheX11>::get();
35 }
36
37 void DeviceListCacheX11::UpdateDeviceList(Display* display) {
38 XDeviceList& new_x_dev_list = x_dev_list_;
39 new_x_dev_list.devices.reset(
40 XListInputDevices(display, &new_x_dev_list.count));
41
42 XIDeviceList& new_xi_dev_list = xi_dev_list_;
43 new_xi_dev_list.devices.reset(
44 IsXI2Available()
45 ? XIQueryDevice(display, XIAllDevices, &new_xi_dev_list.count)
46 : nullptr);
47 }
48
49 const XDeviceList& DeviceListCacheX11::GetXDeviceList(Display* display) {
50 XDeviceList& x_dev_list = x_dev_list_;
51 // Note that the function can be called before any update has taken place.
52 if (!x_dev_list.devices && !x_dev_list.count)
53 x_dev_list.devices.reset(XListInputDevices(display, &x_dev_list.count));
54 return x_dev_list;
55 }
56
57 const XIDeviceList& DeviceListCacheX11::GetXI2DeviceList(Display* display) {
58 XIDeviceList& xi_dev_list = xi_dev_list_;
59 if (!xi_dev_list.devices && !xi_dev_list.count) {
60 xi_dev_list.devices.reset(
61 XIQueryDevice(display, XIAllDevices, &xi_dev_list.count));
62 }
63 return xi_dev_list;
64 }
65
66 } // namespace ui
67
OLDNEW
« no previous file with comments | « ui/events/devices/x11/device_list_cache_x11.h ('k') | ui/events/devices/x11/touch_factory_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698