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

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

Issue 706763003: x11: Always require XI2.2 for X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 6 years, 1 month 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/aura/window_tree_host_x11.cc ('k') | ui/events/devices/x11/touch_factory_x11.cc » ('j') | 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 <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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Check if XInput is available on the system. 158 // Check if XInput is available on the system.
159 xi_opcode_ = -1; 159 xi_opcode_ = -1;
160 int opcode, event, error; 160 int opcode, event, error;
161 if (!XQueryExtension( 161 if (!XQueryExtension(
162 gfx::GetXDisplay(), "XInputExtension", &opcode, &event, &error)) { 162 gfx::GetXDisplay(), "XInputExtension", &opcode, &event, &error)) {
163 VLOG(1) << "X Input extension not available: error=" << error; 163 VLOG(1) << "X Input extension not available: error=" << error;
164 return false; 164 return false;
165 } 165 }
166 166
167 // Check the XInput version. 167 // Check the XInput version.
168 #if defined(USE_XI2_MT) 168 int major = 2, minor = 2;
169 int major = 2, minor = USE_XI2_MT;
170 #else
171 int major = 2, minor = 0;
172 #endif
173 if (XIQueryVersion(gfx::GetXDisplay(), &major, &minor) == BadRequest) { 169 if (XIQueryVersion(gfx::GetXDisplay(), &major, &minor) == BadRequest) {
174 VLOG(1) << "XInput2 not supported in the server."; 170 VLOG(1) << "XInput2 not supported in the server.";
175 return false; 171 return false;
176 } 172 }
177 #if defined(USE_XI2_MT) 173 if (major < 2 || (major == 2 && minor < 2)) {
178 if (major < 2 || (major == 2 && minor < USE_XI2_MT)) {
179 DVLOG(1) << "XI version on server is " << major << "." << minor << ". " 174 DVLOG(1) << "XI version on server is " << major << "." << minor << ". "
180 << "But 2." << USE_XI2_MT << " is required."; 175 << "But 2.2 is required.";
181 return false; 176 return false;
182 } 177 }
183 #endif
184 178
185 xi_opcode_ = opcode; 179 xi_opcode_ = opcode;
186 CHECK_NE(-1, xi_opcode_); 180 CHECK_NE(-1, xi_opcode_);
187 181
188 // Possible XI event types for XIDeviceEvent. See the XI2 protocol 182 // Possible XI event types for XIDeviceEvent. See the XI2 protocol
189 // specification. 183 // specification.
190 xi_device_event_types_[XI_KeyPress] = true; 184 xi_device_event_types_[XI_KeyPress] = true;
191 xi_device_event_types_[XI_KeyRelease] = true; 185 xi_device_event_types_[XI_KeyRelease] = true;
192 xi_device_event_types_[XI_ButtonPress] = true; 186 xi_device_event_types_[XI_ButtonPress] = true;
193 xi_device_event_types_[XI_ButtonRelease] = true; 187 xi_device_event_types_[XI_ButtonRelease] = true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 277 }
284 } 278 }
285 } 279 }
286 280
287 if (possible_cmt && !not_cmt) 281 if (possible_cmt && !not_cmt)
288 cmt_devices_[deviceid] = true; 282 cmt_devices_[deviceid] = true;
289 } 283 }
290 } 284 }
291 285
292 bool DeviceDataManagerX11::GetSlotNumber(const XIDeviceEvent* xiev, int* slot) { 286 bool DeviceDataManagerX11::GetSlotNumber(const XIDeviceEvent* xiev, int* slot) {
293 #if defined(USE_XI2_MT)
294 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 287 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
295 if (!factory->IsMultiTouchDevice(xiev->sourceid)) { 288 if (!factory->IsMultiTouchDevice(xiev->sourceid)) {
296 *slot = 0; 289 *slot = 0;
297 return true; 290 return true;
298 } 291 }
299 return factory->QuerySlotForTrackingID(xiev->detail, slot); 292 return factory->QuerySlotForTrackingID(xiev->detail, slot);
300 #else
301 *slot = 0;
302 return true;
303 #endif
304 } 293 }
305 294
306 void DeviceDataManagerX11::GetEventRawData(const XEvent& xev, EventData* data) { 295 void DeviceDataManagerX11::GetEventRawData(const XEvent& xev, EventData* data) {
307 if (xev.type != GenericEvent) 296 if (xev.type != GenericEvent)
308 return; 297 return;
309 298
310 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); 299 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data);
311 if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum) 300 if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum)
312 return; 301 return;
313 data->clear(); 302 data->clear();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 valuator_lookup_[deviceid][j] = valuator_count_[deviceid]; 656 valuator_lookup_[deviceid][j] = valuator_count_[deviceid];
668 data_type_lookup_[deviceid][valuator_count_[deviceid]] = j; 657 data_type_lookup_[deviceid][valuator_count_[deviceid]] = j;
669 valuator_min_[deviceid][j] = min_value; 658 valuator_min_[deviceid][j] = min_value;
670 valuator_max_[deviceid][j] = max_value; 659 valuator_max_[deviceid][j] = max_value;
671 valuator_count_[deviceid]++; 660 valuator_count_[deviceid]++;
672 } 661 }
673 } 662 }
674 663
675 bool DeviceDataManagerX11::TouchEventNeedsCalibrate( 664 bool DeviceDataManagerX11::TouchEventNeedsCalibrate(
676 unsigned int touch_device_id) const { 665 unsigned int touch_device_id) const {
677 #if defined(OS_CHROMEOS) && defined(USE_XI2_MT) 666 #if defined(OS_CHROMEOS) && defined(USE_X11)
678 int64 touch_display_id = GetDisplayForTouchDevice(touch_device_id); 667 int64 touch_display_id = GetDisplayForTouchDevice(touch_device_id);
679 if (base::SysInfo::IsRunningOnChromeOS() && 668 if (base::SysInfo::IsRunningOnChromeOS() &&
680 touch_display_id == gfx::Display::InternalDisplayId()) { 669 touch_display_id == gfx::Display::InternalDisplayId()) {
681 return true; 670 return true;
682 } 671 }
683 #endif // defined(OS_CHROMEOS) && defined(USE_XI2_MT) 672 #endif // defined(OS_CHROMEOS) && defined(USE_X11)
684 return false; 673 return false;
685 } 674 }
686 675
687 void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys( 676 void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys(
688 scoped_ptr<std::set<KeyboardCode> > excepted_keys) { 677 scoped_ptr<std::set<KeyboardCode> > excepted_keys) {
689 DCHECK(!excepted_keys.get() || 678 DCHECK(!excepted_keys.get() ||
690 !blocked_keyboard_allowed_keys_.get()); 679 !blocked_keyboard_allowed_keys_.get());
691 blocked_keyboard_allowed_keys_ = excepted_keys.Pass(); 680 blocked_keyboard_allowed_keys_ = excepted_keys.Pass();
692 } 681 }
693 682
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 } else { 749 } else {
761 keyboards.erase(it); 750 keyboards.erase(it);
762 ++blocked_iter; 751 ++blocked_iter;
763 } 752 }
764 } 753 }
765 // Notify base class of updated list. 754 // Notify base class of updated list.
766 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); 755 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
767 } 756 }
768 757
769 } // namespace ui 758 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/events/devices/x11/touch_factory_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698