| 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> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 touch_device_list_(), | 32 touch_device_list_(), |
| 33 max_touch_points_(-1), | 33 max_touch_points_(-1), |
| 34 virtual_core_keyboard_device_(-1), | 34 virtual_core_keyboard_device_(-1), |
| 35 id_generator_(0) { | 35 id_generator_(0) { |
| 36 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) | 36 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) |
| 37 return; | 37 return; |
| 38 | 38 |
| 39 XDisplay* display = gfx::GetXDisplay(); | 39 XDisplay* display = gfx::GetXDisplay(); |
| 40 UpdateDeviceList(display); | 40 UpdateDeviceList(display); |
| 41 | 41 |
| 42 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 42 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 43 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && | 43 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && |
| 44 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | 44 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == |
| 45 switches::kTouchEventsDisabled; | 45 switches::kTouchEventsDisabled; |
| 46 } | 46 } |
| 47 | 47 |
| 48 TouchFactory::~TouchFactory() { | 48 TouchFactory::~TouchFactory() { |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 TouchFactory* TouchFactory::GetInstance() { | 52 TouchFactory* TouchFactory::GetInstance() { |
| 53 return Singleton<TouchFactory>::get(); | 53 return Singleton<TouchFactory>::get(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 void TouchFactory::SetTouchDeviceListFromCommandLine() { | 57 void TouchFactory::SetTouchDeviceListFromCommandLine() { |
| 58 // Get a list of pointer-devices that should be treated as touch-devices. | 58 // Get a list of pointer-devices that should be treated as touch-devices. |
| 59 // This is primarily used for testing/debugging touch-event processing when a | 59 // This is primarily used for testing/debugging touch-event processing when a |
| 60 // touch-device isn't available. | 60 // touch-device isn't available. |
| 61 std::string touch_devices = | 61 std::string touch_devices = |
| 62 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 62 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 63 switches::kTouchDevices); | 63 switches::kTouchDevices); |
| 64 | 64 |
| 65 if (!touch_devices.empty()) { | 65 if (!touch_devices.empty()) { |
| 66 std::vector<std::string> devs; | 66 std::vector<std::string> devs; |
| 67 std::vector<unsigned int> device_ids; | 67 std::vector<unsigned int> device_ids; |
| 68 unsigned int devid; | 68 unsigned int devid; |
| 69 base::SplitString(touch_devices, ',', &devs); | 69 base::SplitString(touch_devices, ',', &devs); |
| 70 for (std::vector<std::string>::iterator iter = devs.begin(); | 70 for (std::vector<std::string>::iterator iter = devs.begin(); |
| 71 iter != devs.end(); ++iter) { | 71 iter != devs.end(); ++iter) { |
| 72 if (base::StringToInt(*iter, reinterpret_cast<int*>(&devid))) | 72 if (base::StringToInt(*iter, reinterpret_cast<int*>(&devid))) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (ptr[0] || ptr[1]) | 346 if (ptr[0] || ptr[1]) |
| 347 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 347 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
| 348 } | 348 } |
| 349 XFree(prop_return); | 349 XFree(prop_return); |
| 350 } | 350 } |
| 351 | 351 |
| 352 XCloseDevice(display, device); | 352 XCloseDevice(display, device); |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace ui | 355 } // namespace ui |
| OLD | NEW |