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/base/touch/touch_factory_x11.h" | 5 #include "ui/base/touch/touch_factory_x11.h" |
6 | 6 |
7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
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 #include <X11/extensions/XIproto.h> | 10 #include <X11/extensions/XIproto.h> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
20 #include "ui/base/ui_base_switches.h" | 20 #include "ui/base/ui_base_switches.h" |
21 #include "ui/base/x/device_list_cache_x.h" | 21 #include "ui/base/x/device_list_cache_x.h" |
22 #include "ui/base/x/x11_util.h" | 22 #include "ui/gfx/x/x11_types.h" |
23 | 23 |
24 namespace ui { | 24 namespace ui { |
25 | 25 |
26 TouchFactory::TouchFactory() | 26 TouchFactory::TouchFactory() |
27 : pointer_device_lookup_(), | 27 : pointer_device_lookup_(), |
28 touch_device_available_(false), | 28 touch_device_available_(false), |
29 touch_events_disabled_(false), | 29 touch_events_disabled_(false), |
30 touch_device_list_(), | 30 touch_device_list_(), |
31 #if defined(USE_XI2_MT) | 31 #if defined(USE_XI2_MT) |
32 id_generator_(0), | 32 id_generator_(0), |
33 #endif | 33 #endif |
34 slots_used_() { | 34 slots_used_() { |
35 #if defined(USE_AURA) | 35 #if defined(USE_AURA) |
36 if (!base::MessagePumpForUI::HasXInput2()) | 36 if (!base::MessagePumpForUI::HasXInput2()) |
37 return; | 37 return; |
38 #endif | 38 #endif |
39 | 39 |
40 Display* display = GetXDisplay(); | 40 XDisplay* display = gfx::GetXDisplay(); |
41 UpdateDeviceList(display); | 41 UpdateDeviceList(display); |
42 | 42 |
43 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 43 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
44 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && | 44 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && |
45 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | 45 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == |
46 switches::kTouchEventsDisabled; | 46 switches::kTouchEventsDisabled; |
47 } | 47 } |
48 | 48 |
49 TouchFactory::~TouchFactory() { | 49 TouchFactory::~TouchFactory() { |
50 } | 50 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 void TouchFactory::SetupXI2ForXWindow(Window window) { | 172 void TouchFactory::SetupXI2ForXWindow(Window window) { |
173 // Setup mask for mouse events. It is possible that a device is loaded/plugged | 173 // Setup mask for mouse events. It is possible that a device is loaded/plugged |
174 // in after we have setup XInput2 on a window. In such cases, we need to | 174 // in after we have setup XInput2 on a window. In such cases, we need to |
175 // either resetup XInput2 for the window, so that we get events from the new | 175 // either resetup XInput2 for the window, so that we get events from the new |
176 // device, or we need to listen to events from all devices, and then filter | 176 // device, or we need to listen to events from all devices, and then filter |
177 // the events from uninteresting devices. We do the latter because that's | 177 // the events from uninteresting devices. We do the latter because that's |
178 // simpler. | 178 // simpler. |
179 | 179 |
180 Display* display = ui::GetXDisplay(); | 180 XDisplay* display = gfx::GetXDisplay(); |
181 | 181 |
182 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; | 182 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; |
183 memset(mask, 0, sizeof(mask)); | 183 memset(mask, 0, sizeof(mask)); |
184 | 184 |
185 #if defined(USE_XI2_MT) | 185 #if defined(USE_XI2_MT) |
186 XISetMask(mask, XI_TouchBegin); | 186 XISetMask(mask, XI_TouchBegin); |
187 XISetMask(mask, XI_TouchUpdate); | 187 XISetMask(mask, XI_TouchUpdate); |
188 XISetMask(mask, XI_TouchEnd); | 188 XISetMask(mask, XI_TouchEnd); |
189 #endif | 189 #endif |
190 XISetMask(mask, XI_ButtonPress); | 190 XISetMask(mask, XI_ButtonPress); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 iter != devices.end(); ++iter) { | 262 iter != devices.end(); ++iter) { |
263 DCHECK(*iter < touch_device_lookup_.size()); | 263 DCHECK(*iter < touch_device_lookup_.size()); |
264 touch_device_lookup_[*iter] = true; | 264 touch_device_lookup_[*iter] = true; |
265 touch_device_list_[*iter] = true; | 265 touch_device_list_[*iter] = true; |
266 } | 266 } |
267 touch_device_available_ = true; | 267 touch_device_available_ = true; |
268 touch_events_disabled_ = false; | 268 touch_events_disabled_ = false; |
269 } | 269 } |
270 | 270 |
271 } // namespace ui | 271 } // namespace ui |
OLD | NEW |