| OLD | NEW |
| 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> |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool DeviceDataManagerX11::IsXInput2Available() const { | 214 bool DeviceDataManagerX11::IsXInput2Available() const { |
| 215 return xi_opcode_ != -1; | 215 return xi_opcode_ != -1; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void DeviceDataManagerX11::UpdateDeviceList(Display* display) { | 218 void DeviceDataManagerX11::UpdateDeviceList(Display* display) { |
| 219 cmt_devices_.reset(); | 219 cmt_devices_.reset(); |
| 220 touchpads_.reset(); | 220 touchpads_.reset(); |
| 221 scrollclass_devices_.reset(); | |
| 222 master_pointers_.clear(); | 221 master_pointers_.clear(); |
| 223 for (int i = 0; i < kMaxDeviceNum; ++i) { | 222 for (int i = 0; i < kMaxDeviceNum; ++i) { |
| 224 valuator_count_[i] = 0; | 223 valuator_count_[i] = 0; |
| 225 valuator_lookup_[i].clear(); | 224 valuator_lookup_[i].clear(); |
| 226 data_type_lookup_[i].clear(); | 225 data_type_lookup_[i].clear(); |
| 227 valuator_min_[i].clear(); | 226 valuator_min_[i].clear(); |
| 228 valuator_max_[i].clear(); | 227 valuator_max_[i].clear(); |
| 229 scroll_data_[i].horizontal.number = -1; | 228 scroll_data_[i].horizontal.number = -1; |
| 230 scroll_data_[i].horizontal.seen = false; | 229 scroll_data_[i].horizontal.seen = false; |
| 231 scroll_data_[i].vertical.number = -1; | 230 scroll_data_[i].vertical.number = -1; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return cmt_devices_[xievent->sourceid]; | 416 return cmt_devices_[xievent->sourceid]; |
| 418 } | 417 } |
| 419 | 418 |
| 420 int DeviceDataManagerX11::GetScrollClassEventDetail(const XEvent& xev) const { | 419 int DeviceDataManagerX11::GetScrollClassEventDetail(const XEvent& xev) const { |
| 421 if (xev.type != GenericEvent) | 420 if (xev.type != GenericEvent) |
| 422 return SCROLL_TYPE_NO_SCROLL; | 421 return SCROLL_TYPE_NO_SCROLL; |
| 423 | 422 |
| 424 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev.xcookie.data); | 423 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev.xcookie.data); |
| 425 if (xievent->sourceid >= kMaxDeviceNum) | 424 if (xievent->sourceid >= kMaxDeviceNum) |
| 426 return SCROLL_TYPE_NO_SCROLL; | 425 return SCROLL_TYPE_NO_SCROLL; |
| 427 if (!scrollclass_devices_[xievent->sourceid]) | |
| 428 return SCROLL_TYPE_NO_SCROLL; | |
| 429 int horizontal_id = scroll_data_[xievent->sourceid].horizontal.number; | 426 int horizontal_id = scroll_data_[xievent->sourceid].horizontal.number; |
| 430 int vertical_id = scroll_data_[xievent->sourceid].vertical.number; | 427 int vertical_id = scroll_data_[xievent->sourceid].vertical.number; |
| 431 return (XIMaskIsSet(xievent->valuators.mask, horizontal_id) | 428 return (horizontal_id != -1 && |
| 429 XIMaskIsSet(xievent->valuators.mask, horizontal_id) |
| 432 ? SCROLL_TYPE_HORIZONTAL | 430 ? SCROLL_TYPE_HORIZONTAL |
| 433 : 0) | | 431 : 0) | |
| 434 (XIMaskIsSet(xievent->valuators.mask, vertical_id) | 432 (vertical_id != -1 && XIMaskIsSet(xievent->valuators.mask, vertical_id) |
| 435 ? SCROLL_TYPE_VERTICAL | 433 ? SCROLL_TYPE_VERTICAL |
| 436 : 0); | 434 : 0); |
| 437 } | 435 } |
| 438 | 436 |
| 439 int DeviceDataManagerX11::GetScrollClassDeviceDetail(const XEvent& xev) const { | 437 int DeviceDataManagerX11::GetScrollClassDeviceDetail(const XEvent& xev) const { |
| 440 if (xev.type != GenericEvent) | 438 if (xev.type != GenericEvent) |
| 441 return SCROLL_TYPE_NO_SCROLL; | 439 return SCROLL_TYPE_NO_SCROLL; |
| 442 | 440 |
| 443 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); | 441 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); |
| 444 if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum) | 442 if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum) |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 info.vertical.position = 0; | 778 info.vertical.position = 0; |
| 781 info.vertical.seen = false; | 779 info.vertical.seen = false; |
| 782 break; | 780 break; |
| 783 case XIScrollTypeHorizontal: | 781 case XIScrollTypeHorizontal: |
| 784 info.horizontal.number = scroll_class_info->number; | 782 info.horizontal.number = scroll_class_info->number; |
| 785 info.horizontal.increment = scroll_class_info->increment; | 783 info.horizontal.increment = scroll_class_info->increment; |
| 786 info.horizontal.position = 0; | 784 info.horizontal.position = 0; |
| 787 info.horizontal.seen = false; | 785 info.horizontal.seen = false; |
| 788 break; | 786 break; |
| 789 } | 787 } |
| 790 scrollclass_devices_[deviceid] = true; | |
| 791 } | 788 } |
| 792 | 789 |
| 793 double DeviceDataManagerX11::ExtractAndUpdateScrollOffset( | 790 double DeviceDataManagerX11::ExtractAndUpdateScrollOffset( |
| 794 ScrollInfo::AxisInfo* axis, | 791 ScrollInfo::AxisInfo* axis, |
| 795 double valuator) const { | 792 double valuator) const { |
| 796 double offset = 0; | 793 double offset = 0; |
| 797 if (axis->seen) | 794 if (axis->seen) |
| 798 offset = axis->position - valuator; | 795 offset = axis->position - valuator; |
| 799 axis->seen = true; | 796 axis->seen = true; |
| 800 axis->position = valuator; | 797 axis->position = valuator; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 } else { | 871 } else { |
| 875 keyboards.erase(it); | 872 keyboards.erase(it); |
| 876 ++blocked_iter; | 873 ++blocked_iter; |
| 877 } | 874 } |
| 878 } | 875 } |
| 879 // Notify base class of updated list. | 876 // Notify base class of updated list. |
| 880 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); | 877 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); |
| 881 } | 878 } |
| 882 | 879 |
| 883 } // namespace ui | 880 } // namespace ui |
| OLD | NEW |