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

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

Issue 2153683002: Added a command line switch to disable xinput2, enabled xinput2 by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devices/x11/device_data_manager_x11.h" 5 #include "ui/events/devices/x11/device_data_manager_x11.h"
6 6
7 #include <stddef.h> 7 #include <stddef.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/Xlib.h> 10 #include <X11/Xlib.h>
11 11
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/memory/singleton.h" 19 #include "base/memory/singleton.h"
19 #include "base/sys_info.h" 20 #include "base/sys_info.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "ui/display/display.h" 22 #include "ui/display/display.h"
22 #include "ui/events/devices/x11/device_list_cache_x11.h" 23 #include "ui/events/devices/x11/device_list_cache_x11.h"
23 #include "ui/events/devices/x11/touch_factory_x11.h" 24 #include "ui/events/devices/x11/touch_factory_x11.h"
25 #include "ui/events/devices/x11/ui_events_devices_x11_switches.h"
24 #include "ui/events/event_constants.h" 26 #include "ui/events/event_constants.h"
25 #include "ui/events/event_switches.h" 27 #include "ui/events/event_switches.h"
26 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 28 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
27 #include "ui/gfx/geometry/point3_f.h" 29 #include "ui/gfx/geometry/point3_f.h"
28 #include "ui/gfx/x/x11_types.h" 30 #include "ui/gfx/x/x11_types.h"
29 31
30 // XIScrollClass was introduced in XI 2.1 so we need to define it here 32 // XIScrollClass was introduced in XI 2.1 so we need to define it here
31 // for backward-compatibility with older versions of XInput. 33 // for backward-compatibility with older versions of XInput.
32 #if !defined(XIScrollClass) 34 #if !defined(XIScrollClass)
33 #define XIScrollClass 3 35 #define XIScrollClass 3
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 119
118 template <typename Iterator> 120 template <typename Iterator>
119 Iterator FindDeviceWithId(Iterator begin, Iterator end, int id) { 121 Iterator FindDeviceWithId(Iterator begin, Iterator end, int id) {
120 for (auto it = begin; it != end; ++it) { 122 for (auto it = begin; it != end; ++it) {
121 if (it->id == id) 123 if (it->id == id)
122 return it; 124 return it;
123 } 125 }
124 return end; 126 return end;
125 } 127 }
126 128
129 bool IsHighPrecisionScrollingDisabled() {
130 return base::CommandLine::ForCurrentProcess()->HasSwitch(
131 switches::kDisableHighPrecisionScrolling);
132 }
133
127 } // namespace 134 } // namespace
128 135
129 bool DeviceDataManagerX11::IsCMTDataType(const int type) { 136 bool DeviceDataManagerX11::IsCMTDataType(const int type) {
130 return (type >= kCMTDataTypeStart) && (type <= kCMTDataTypeEnd); 137 return (type >= kCMTDataTypeStart) && (type <= kCMTDataTypeEnd);
131 } 138 }
132 139
133 bool DeviceDataManagerX11::IsTouchDataType(const int type) { 140 bool DeviceDataManagerX11::IsTouchDataType(const int type) {
134 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd); 141 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd);
135 } 142 }
136 143
(...skipping 11 matching lines...) Expand all
148 set_instance(device_data_manager); 155 set_instance(device_data_manager);
149 } 156 }
150 157
151 // static 158 // static
152 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() { 159 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() {
153 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()); 160 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance());
154 } 161 }
155 162
156 DeviceDataManagerX11::DeviceDataManagerX11() 163 DeviceDataManagerX11::DeviceDataManagerX11()
157 : xi_opcode_(-1), 164 : xi_opcode_(-1),
165 high_precision_scrolling_disabled_(IsHighPrecisionScrollingDisabled()),
158 atom_cache_(gfx::GetXDisplay(), kCachedAtoms), 166 atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
159 button_map_count_(0) { 167 button_map_count_(0) {
160 CHECK(gfx::GetXDisplay()); 168 CHECK(gfx::GetXDisplay());
161 InitializeXInputInternal(); 169 InitializeXInputInternal();
162 170
163 // Make sure the sizes of enum and kCachedAtoms are aligned. 171 // Make sure the sizes of enum and kCachedAtoms are aligned.
164 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); 172 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1);
165 UpdateDeviceList(gfx::GetXDisplay()); 173 UpdateDeviceList(gfx::GetXDisplay());
166 UpdateButtonMap(); 174 UpdateButtonMap();
167 } 175 }
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 valuator_max_[deviceid][data_type] = valuator_class_info->max; 772 valuator_max_[deviceid][data_type] = valuator_class_info->max;
765 return IsCMTDataType(data_type); 773 return IsCMTDataType(data_type);
766 } 774 }
767 775
768 void DeviceDataManagerX11::UpdateScrollClassDevice( 776 void DeviceDataManagerX11::UpdateScrollClassDevice(
769 XIScrollClassInfo* scroll_class_info, 777 XIScrollClassInfo* scroll_class_info,
770 int deviceid) { 778 int deviceid) {
771 DCHECK(deviceid >= 0 && deviceid < kMaxDeviceNum); 779 DCHECK(deviceid >= 0 && deviceid < kMaxDeviceNum);
772 ScrollInfo& info = scroll_data_[deviceid]; 780 ScrollInfo& info = scroll_data_[deviceid];
773 781
774 // TODO: xinput2 is disabled until edge cases are fixed. 782 if (high_precision_scrolling_disabled_) {
775 // http://crbug.com/616308 783 return;
776 return; 784 }
sadrul 2016/07/20 17:02:26 no {} Move after the DCHECK() above
Will Shackleton 2016/07/25 20:53:38 Done.
777 785
778 bool legacy_scroll_available = 786 bool legacy_scroll_available =
779 (scroll_class_info->flags & XIScrollFlagNoEmulation) == 0; 787 (scroll_class_info->flags & XIScrollFlagNoEmulation) == 0;
780 // If the device's highest resolution is lower than the resolution of xinput1 788 // If the device's highest resolution is lower than the resolution of xinput1
781 // then use xinput1's events instead (ie. don't configure smooth scrolling). 789 // then use xinput1's events instead (ie. don't configure smooth scrolling).
782 if (legacy_scroll_available && 790 if (legacy_scroll_available &&
783 std::abs(scroll_class_info->increment) <= 1.0) { 791 std::abs(scroll_class_info->increment) <= 1.0) {
784 return; 792 return;
785 } 793 }
786 794
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } else { 892 } else {
885 keyboards.erase(it); 893 keyboards.erase(it);
886 ++blocked_iter; 894 ++blocked_iter;
887 } 895 }
888 } 896 }
889 // Notify base class of updated list. 897 // Notify base class of updated list.
890 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); 898 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
891 } 899 }
892 900
893 } // namespace ui 901 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698