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

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: Removed ui_events_devices_x11_switches files 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
« no previous file with comments | « ui/events/devices/x11/device_data_manager_x11.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
24 #include "ui/events/event_constants.h" 25 #include "ui/events/event_constants.h"
25 #include "ui/events/event_switches.h" 26 #include "ui/events/event_switches.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 template <typename Iterator> 119 template <typename Iterator>
119 Iterator FindDeviceWithId(Iterator begin, Iterator end, int id) { 120 Iterator FindDeviceWithId(Iterator begin, Iterator end, int id) {
120 for (auto it = begin; it != end; ++it) { 121 for (auto it = begin; it != end; ++it) {
121 if (it->id == id) 122 if (it->id == id)
122 return it; 123 return it;
123 } 124 }
124 return end; 125 return end;
125 } 126 }
126 127
128 // Disables high precision scrolling in X11
129 const char kDisableHighPrecisionScrolling[] =
130 "disable-high-precision-scrolling";
131
132 bool IsHighPrecisionScrollingDisabled() {
133 return base::CommandLine::ForCurrentProcess()->HasSwitch(
134 kDisableHighPrecisionScrolling);
135 }
136
127 } // namespace 137 } // namespace
128 138
129 bool DeviceDataManagerX11::IsCMTDataType(const int type) { 139 bool DeviceDataManagerX11::IsCMTDataType(const int type) {
130 return (type >= kCMTDataTypeStart) && (type <= kCMTDataTypeEnd); 140 return (type >= kCMTDataTypeStart) && (type <= kCMTDataTypeEnd);
131 } 141 }
132 142
133 bool DeviceDataManagerX11::IsTouchDataType(const int type) { 143 bool DeviceDataManagerX11::IsTouchDataType(const int type) {
134 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd); 144 return (type >= kTouchDataTypeStart) && (type <= kTouchDataTypeEnd);
135 } 145 }
136 146
(...skipping 11 matching lines...) Expand all
148 set_instance(device_data_manager); 158 set_instance(device_data_manager);
149 } 159 }
150 160
151 // static 161 // static
152 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() { 162 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() {
153 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()); 163 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance());
154 } 164 }
155 165
156 DeviceDataManagerX11::DeviceDataManagerX11() 166 DeviceDataManagerX11::DeviceDataManagerX11()
157 : xi_opcode_(-1), 167 : xi_opcode_(-1),
168 high_precision_scrolling_disabled_(IsHighPrecisionScrollingDisabled()),
158 atom_cache_(gfx::GetXDisplay(), kCachedAtoms), 169 atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
159 button_map_count_(0) { 170 button_map_count_(0) {
160 CHECK(gfx::GetXDisplay()); 171 CHECK(gfx::GetXDisplay());
161 InitializeXInputInternal(); 172 InitializeXInputInternal();
162 173
163 // Make sure the sizes of enum and kCachedAtoms are aligned. 174 // Make sure the sizes of enum and kCachedAtoms are aligned.
164 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); 175 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1);
165 UpdateDeviceList(gfx::GetXDisplay()); 176 UpdateDeviceList(gfx::GetXDisplay());
166 UpdateButtonMap(); 177 UpdateButtonMap();
167 } 178 }
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 valuator_lookup_[deviceid][data_type] = valuator_class_info->number; 772 valuator_lookup_[deviceid][data_type] = valuator_class_info->number;
762 data_type_lookup_[deviceid][valuator_class_info->number] = data_type; 773 data_type_lookup_[deviceid][valuator_class_info->number] = data_type;
763 valuator_min_[deviceid][data_type] = valuator_class_info->min; 774 valuator_min_[deviceid][data_type] = valuator_class_info->min;
764 valuator_max_[deviceid][data_type] = valuator_class_info->max; 775 valuator_max_[deviceid][data_type] = valuator_class_info->max;
765 return IsCMTDataType(data_type); 776 return IsCMTDataType(data_type);
766 } 777 }
767 778
768 void DeviceDataManagerX11::UpdateScrollClassDevice( 779 void DeviceDataManagerX11::UpdateScrollClassDevice(
769 XIScrollClassInfo* scroll_class_info, 780 XIScrollClassInfo* scroll_class_info,
770 int deviceid) { 781 int deviceid) {
782 if (high_precision_scrolling_disabled_)
783 return;
784
771 DCHECK(deviceid >= 0 && deviceid < kMaxDeviceNum); 785 DCHECK(deviceid >= 0 && deviceid < kMaxDeviceNum);
772 ScrollInfo& info = scroll_data_[deviceid]; 786 ScrollInfo& info = scroll_data_[deviceid];
773 787
774 // TODO: xinput2 is disabled until edge cases are fixed.
775 // http://crbug.com/616308
776 return;
777
778 bool legacy_scroll_available = 788 bool legacy_scroll_available =
779 (scroll_class_info->flags & XIScrollFlagNoEmulation) == 0; 789 (scroll_class_info->flags & XIScrollFlagNoEmulation) == 0;
780 // If the device's highest resolution is lower than the resolution of xinput1 790 // 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). 791 // then use xinput1's events instead (ie. don't configure smooth scrolling).
782 if (legacy_scroll_available && 792 if (legacy_scroll_available &&
783 std::abs(scroll_class_info->increment) <= 1.0) { 793 std::abs(scroll_class_info->increment) <= 1.0) {
784 return; 794 return;
785 } 795 }
786 796
787 switch (scroll_class_info->scroll_type) { 797 switch (scroll_class_info->scroll_type) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } else { 894 } else {
885 keyboards.erase(it); 895 keyboards.erase(it);
886 ++blocked_iter; 896 ++blocked_iter;
887 } 897 }
888 } 898 }
889 // Notify base class of updated list. 899 // Notify base class of updated list.
890 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); 900 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
891 } 901 }
892 902
893 } // namespace ui 903 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/devices/x11/device_data_manager_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698