| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/x/device_data_manager.h" | 5 #include "ui/base/x/device_data_manager.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput.h> | 7 #include <X11/extensions/XInput.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 bool DeviceDataManager::IsTouchDataType(const int type) { | 109 bool DeviceDataManager::IsTouchDataType(const int type) { |
| 110 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd); | 110 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd); |
| 111 } | 111 } |
| 112 | 112 |
| 113 DeviceDataManager* DeviceDataManager::GetInstance() { | 113 DeviceDataManager* DeviceDataManager::GetInstance() { |
| 114 return Singleton<DeviceDataManager>::get(); | 114 return Singleton<DeviceDataManager>::get(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 DeviceDataManager::DeviceDataManager() | 117 DeviceDataManager::DeviceDataManager() |
| 118 : natural_scroll_enabled_(false), | 118 : natural_scroll_enabled_(false), |
| 119 atom_cache_(ui::GetXDisplay(), kCachedAtoms) { | 119 atom_cache_(gfx::GetXDisplay(), kCachedAtoms) { |
| 120 InitializeXInputInternal(); | 120 InitializeXInputInternal(); |
| 121 | 121 |
| 122 // Make sure the sizes of enum and kCachedAtoms are aligned. | 122 // Make sure the sizes of enum and kCachedAtoms are aligned. |
| 123 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); | 123 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); |
| 124 UpdateDeviceList(ui::GetXDisplay()); | 124 UpdateDeviceList(gfx::GetXDisplay()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 DeviceDataManager::~DeviceDataManager() { | 127 DeviceDataManager::~DeviceDataManager() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool DeviceDataManager::InitializeXInputInternal() { | 130 bool DeviceDataManager::InitializeXInputInternal() { |
| 131 // Check if XInput is available on the system. | 131 // Check if XInput is available on the system. |
| 132 xi_opcode_ = -1; | 132 xi_opcode_ = -1; |
| 133 int opcode, event, error; | 133 int opcode, event, error; |
| 134 if (!XQueryExtension( | 134 if (!XQueryExtension( |
| 135 ui::GetXDisplay(), "XInputExtension", &opcode, &event, &error)) { | 135 gfx::GetXDisplay(), "XInputExtension", &opcode, &event, &error)) { |
| 136 VLOG(1) << "X Input extension not available: error=" << error; | 136 VLOG(1) << "X Input extension not available: error=" << error; |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 xi_opcode_ = opcode; | 139 xi_opcode_ = opcode; |
| 140 | 140 |
| 141 // Check the XInput version. | 141 // Check the XInput version. |
| 142 #if defined(USE_XI2_MT) | 142 #if defined(USE_XI2_MT) |
| 143 int major = 2, minor = USE_XI2_MT; | 143 int major = 2, minor = USE_XI2_MT; |
| 144 #else | 144 #else |
| 145 int major = 2, minor = 0; | 145 int major = 2, minor = 0; |
| 146 #endif | 146 #endif |
| 147 if (XIQueryVersion(ui::GetXDisplay(), &major, &minor) == BadRequest) { | 147 if (XIQueryVersion(gfx::GetXDisplay(), &major, &minor) == BadRequest) { |
| 148 VLOG(1) << "XInput2 not supported in the server."; | 148 VLOG(1) << "XInput2 not supported in the server."; |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Possible XI event types for XIDeviceEvent. See the XI2 protocol | 152 // Possible XI event types for XIDeviceEvent. See the XI2 protocol |
| 153 // specification. | 153 // specification. |
| 154 xi_device_event_types_[XI_KeyPress] = true; | 154 xi_device_event_types_[XI_KeyPress] = true; |
| 155 xi_device_event_types_[XI_KeyRelease] = true; | 155 xi_device_event_types_[XI_KeyRelease] = true; |
| 156 xi_device_event_types_[XI_ButtonPress] = true; | 156 xi_device_event_types_[XI_ButtonPress] = true; |
| 157 xi_device_event_types_[XI_ButtonRelease] = true; | 157 xi_device_event_types_[XI_ButtonRelease] = true; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 int val_index, | 577 int val_index, |
| 578 DataType data_type, | 578 DataType data_type, |
| 579 double min, | 579 double min, |
| 580 double max) { | 580 double max) { |
| 581 valuator_lookup_[deviceid][data_type] = val_index; | 581 valuator_lookup_[deviceid][data_type] = val_index; |
| 582 data_type_lookup_[deviceid][val_index] = data_type; | 582 data_type_lookup_[deviceid][val_index] = data_type; |
| 583 valuator_min_[deviceid][data_type] = min; | 583 valuator_min_[deviceid][data_type] = min; |
| 584 valuator_max_[deviceid][data_type] = max; | 584 valuator_max_[deviceid][data_type] = max; |
| 585 } | 585 } |
| 586 } // namespace ui | 586 } // namespace ui |
| OLD | NEW |