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/x/touch_factory_x11.h" | 5 #include "ui/events/x/touch_factory_x11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
11 #include <X11/extensions/XIproto.h> | 11 #include <X11/extensions/XIproto.h> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
21 #include "ui/events/event_switches.h" | 21 #include "ui/events/event_switches.h" |
22 #include "ui/events/x/device_data_manager.h" | 22 #include "ui/events/x/device_data_manager_x11.h" |
23 #include "ui/events/x/device_list_cache_x.h" | 23 #include "ui/events/x/device_list_cache_x.h" |
24 #include "ui/gfx/x/x11_types.h" | 24 #include "ui/gfx/x/x11_types.h" |
25 | 25 |
26 namespace ui { | 26 namespace ui { |
27 | 27 |
28 TouchFactory::TouchFactory() | 28 TouchFactory::TouchFactory() |
29 : pointer_device_lookup_(), | 29 : pointer_device_lookup_(), |
30 touch_device_available_(false), | 30 touch_device_available_(false), |
31 touch_events_disabled_(false), | 31 touch_events_disabled_(false), |
32 touch_device_list_(), | 32 touch_device_list_(), |
33 max_touch_points_(-1), | 33 max_touch_points_(-1), |
34 id_generator_(0) { | 34 id_generator_(0) { |
35 if (!DeviceDataManager::GetInstance()->IsXInput2Available()) | 35 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) |
36 return; | 36 return; |
37 | 37 |
38 XDisplay* display = gfx::GetXDisplay(); | 38 XDisplay* display = gfx::GetXDisplay(); |
39 UpdateDeviceList(display); | 39 UpdateDeviceList(display); |
40 | 40 |
41 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 41 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
42 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && | 42 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && |
43 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | 43 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == |
44 switches::kTouchEventsDisabled; | 44 switches::kTouchEventsDisabled; |
45 } | 45 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false); | 97 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false); |
98 for (int i = 0; i < dev_list.count; i++) { | 98 for (int i = 0; i < dev_list.count; i++) { |
99 if (dev_list[i].type == xi_touchscreen) { | 99 if (dev_list[i].type == xi_touchscreen) { |
100 touch_device_lookup_[dev_list[i].id] = true; | 100 touch_device_lookup_[dev_list[i].id] = true; |
101 touch_device_list_[dev_list[i].id] = false; | 101 touch_device_list_[dev_list[i].id] = false; |
102 touch_device_available_ = true; | 102 touch_device_available_ = true; |
103 } | 103 } |
104 } | 104 } |
105 #endif | 105 #endif |
106 | 106 |
107 if (!DeviceDataManager::GetInstance()->IsXInput2Available()) | 107 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) |
108 return; | 108 return; |
109 | 109 |
110 // Instead of asking X for the list of devices all the time, let's maintain a | 110 // Instead of asking X for the list of devices all the time, let's maintain a |
111 // list of pointer devices we care about. | 111 // list of pointer devices we care about. |
112 // It should not be necessary to select for slave devices. XInput2 provides | 112 // It should not be necessary to select for slave devices. XInput2 provides |
113 // enough information to the event callback to decide which slave device | 113 // enough information to the event callback to decide which slave device |
114 // triggered the event, thus decide whether the 'pointer event' is a | 114 // triggered the event, thus decide whether the 'pointer event' is a |
115 // 'mouse event' or a 'touch event'. | 115 // 'mouse event' or a 'touch event'. |
116 // However, on some desktops, some events from a master pointer are | 116 // However, on some desktops, some events from a master pointer are |
117 // not delivered to the client. So we select for slave devices instead. | 117 // not delivered to the client. So we select for slave devices instead. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (ptr[0] || ptr[1]) | 318 if (ptr[0] || ptr[1]) |
319 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 319 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
320 } | 320 } |
321 XFree(prop_return); | 321 XFree(prop_return); |
322 } | 322 } |
323 | 323 |
324 XCloseDevice(display, device); | 324 XCloseDevice(display, device); |
325 } | 325 } |
326 | 326 |
327 } // namespace ui | 327 } // namespace ui |
OLD | NEW |