| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/event_constants.h" | 5 #include "ui/events/event_constants.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
| 10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 436 } |
| 437 case XI_Motion: { | 437 case XI_Motion: { |
| 438 bool is_cancel; | 438 bool is_cancel; |
| 439 DeviceDataManagerX11* devices = DeviceDataManagerX11::GetInstance(); | 439 DeviceDataManagerX11* devices = DeviceDataManagerX11::GetInstance(); |
| 440 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) | 440 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) |
| 441 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; | 441 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; |
| 442 if (devices->IsScrollEvent(native_event)) { | 442 if (devices->IsScrollEvent(native_event)) { |
| 443 return devices->IsTouchpadXInputEvent(native_event) ? ET_SCROLL | 443 return devices->IsTouchpadXInputEvent(native_event) ? ET_SCROLL |
| 444 : ET_MOUSEWHEEL; | 444 : ET_MOUSEWHEEL; |
| 445 } | 445 } |
| 446 if (devices->GetScrollClassEventDetail(native_event) != |
| 447 SCROLL_TYPE_NO_SCROLL) |
| 448 return ET_MOUSEWHEEL; |
| 446 if (devices->IsCMTMetricsEvent(native_event)) | 449 if (devices->IsCMTMetricsEvent(native_event)) |
| 447 return ET_UMA_DATA; | 450 return ET_UMA_DATA; |
| 448 if (GetButtonMaskForX2Event(xievent)) | 451 if (GetButtonMaskForX2Event(xievent)) |
| 449 return ET_MOUSE_DRAGGED; | 452 return ET_MOUSE_DRAGGED; |
| 450 if (DeviceDataManagerX11::GetInstance()->HasEventData( | 453 if (DeviceDataManagerX11::GetInstance()->HasEventData( |
| 451 xievent, DeviceDataManagerX11::DT_CMT_SCROLL_X) || | 454 xievent, DeviceDataManagerX11::DT_CMT_SCROLL_X) || |
| 452 DeviceDataManagerX11::GetInstance()->HasEventData( | 455 DeviceDataManagerX11::GetInstance()->HasEventData( |
| 453 xievent, DeviceDataManagerX11::DT_CMT_SCROLL_Y)) { | 456 xievent, DeviceDataManagerX11::DT_CMT_SCROLL_Y)) { |
| 454 // Don't produce mouse move events for mousewheel scrolls. | 457 // Don't produce mouse move events for mousewheel scrolls. |
| 455 return ET_UNKNOWN; | 458 return ET_UNKNOWN; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 force = 0.0; | 782 force = 0.0; |
| 780 return force; | 783 return force; |
| 781 } | 784 } |
| 782 | 785 |
| 783 bool GetScrollOffsets(const base::NativeEvent& native_event, | 786 bool GetScrollOffsets(const base::NativeEvent& native_event, |
| 784 float* x_offset, | 787 float* x_offset, |
| 785 float* y_offset, | 788 float* y_offset, |
| 786 float* x_offset_ordinal, | 789 float* x_offset_ordinal, |
| 787 float* y_offset_ordinal, | 790 float* y_offset_ordinal, |
| 788 int* finger_count) { | 791 int* finger_count) { |
| 789 if (!DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) | 792 if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) { |
| 790 return false; | 793 // Temp values to prevent passing NULLs to DeviceDataManager. |
| 794 float x_offset_, y_offset_; |
| 795 float x_offset_ordinal_, y_offset_ordinal_; |
| 796 int finger_count_; |
| 797 if (!x_offset) |
| 798 x_offset = &x_offset_; |
| 799 if (!y_offset) |
| 800 y_offset = &y_offset_; |
| 801 if (!x_offset_ordinal) |
| 802 x_offset_ordinal = &x_offset_ordinal_; |
| 803 if (!y_offset_ordinal) |
| 804 y_offset_ordinal = &y_offset_ordinal_; |
| 805 if (!finger_count) |
| 806 finger_count = &finger_count_; |
| 791 | 807 |
| 792 // Temp values to prevent passing NULLs to DeviceDataManager. | 808 DeviceDataManagerX11::GetInstance()->GetScrollOffsets( |
| 793 float x_offset_, y_offset_; | 809 native_event, x_offset, y_offset, x_offset_ordinal, y_offset_ordinal, |
| 794 float x_offset_ordinal_, y_offset_ordinal_; | 810 finger_count); |
| 795 int finger_count_; | 811 return true; |
| 796 if (!x_offset) | 812 } |
| 797 x_offset = &x_offset_; | |
| 798 if (!y_offset) | |
| 799 y_offset = &y_offset_; | |
| 800 if (!x_offset_ordinal) | |
| 801 x_offset_ordinal = &x_offset_ordinal_; | |
| 802 if (!y_offset_ordinal) | |
| 803 y_offset_ordinal = &y_offset_ordinal_; | |
| 804 if (!finger_count) | |
| 805 finger_count = &finger_count_; | |
| 806 | 813 |
| 807 DeviceDataManagerX11::GetInstance()->GetScrollOffsets( | 814 if (DeviceDataManagerX11::GetInstance()->GetScrollClassDeviceDetail( |
| 808 native_event, | 815 native_event) != SCROLL_TYPE_NO_SCROLL) { |
| 809 x_offset, y_offset, | 816 double x_scroll_offset, y_scroll_offset; |
| 810 x_offset_ordinal, y_offset_ordinal, | 817 DeviceDataManagerX11::GetInstance()->GetScrollClassOffsets( |
| 811 finger_count); | 818 native_event, &x_scroll_offset, &y_scroll_offset); |
| 812 return true; | 819 *x_offset = x_scroll_offset * kWheelScrollAmount; |
| 820 *y_offset = y_scroll_offset * kWheelScrollAmount; |
| 821 return true; |
| 822 } |
| 823 return false; |
| 813 } | 824 } |
| 814 | 825 |
| 815 bool GetFlingData(const base::NativeEvent& native_event, | 826 bool GetFlingData(const base::NativeEvent& native_event, |
| 816 float* vx, | 827 float* vx, |
| 817 float* vy, | 828 float* vy, |
| 818 float* vx_ordinal, | 829 float* vx_ordinal, |
| 819 float* vy_ordinal, | 830 float* vy_ordinal, |
| 820 bool* is_cancel) { | 831 bool* is_cancel) { |
| 821 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event)) | 832 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event)) |
| 822 return false; | 833 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 xievent->detail = | 894 xievent->detail = |
| 884 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); | 895 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); |
| 885 break; | 896 break; |
| 886 } | 897 } |
| 887 default: | 898 default: |
| 888 break; | 899 break; |
| 889 } | 900 } |
| 890 } | 901 } |
| 891 | 902 |
| 892 } // namespace ui | 903 } // namespace ui |
| OLD | NEW |