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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 float x_offset, y_offset; | 690 float x_offset, y_offset; |
688 if (GetScrollOffsets( | 691 if (GetScrollOffsets( |
689 native_event, &x_offset, &y_offset, NULL, NULL, NULL)) { | 692 native_event, &x_offset, &y_offset, NULL, NULL, NULL)) { |
690 return gfx::Vector2d(static_cast<int>(x_offset), | 693 return gfx::Vector2d(static_cast<int>(x_offset), |
691 static_cast<int>(y_offset)); | 694 static_cast<int>(y_offset)); |
692 } | 695 } |
693 | 696 |
694 int button = native_event->type == GenericEvent ? | 697 int button = native_event->type == GenericEvent ? |
695 EventButtonFromNative(native_event) : native_event->xbutton.button; | 698 EventButtonFromNative(native_event) : native_event->xbutton.button; |
696 | 699 |
| 700 int scroll_class_type = |
| 701 DeviceDataManagerX11::GetInstance()->GetScrollClassDeviceDetail( |
| 702 native_event); |
| 703 bool vertical_scroll_class = scroll_class_type & SCROLL_TYPE_VERTICAL; |
| 704 bool horizontal_scroll_class = scroll_class_type & SCROLL_TYPE_HORIZONTAL; |
| 705 |
697 switch (button) { | 706 switch (button) { |
698 case 4: | 707 case 4: |
699 return gfx::Vector2d(0, kWheelScrollAmount); | 708 return gfx::Vector2d(0, vertical_scroll_class ? 0 : kWheelScrollAmount); |
700 case 5: | 709 case 5: |
701 return gfx::Vector2d(0, -kWheelScrollAmount); | 710 return gfx::Vector2d(0, vertical_scroll_class ? 0 : -kWheelScrollAmount); |
702 case 6: | 711 case 6: |
703 return gfx::Vector2d(kWheelScrollAmount, 0); | 712 return gfx::Vector2d(horizontal_scroll_class ? 0 : kWheelScrollAmount, 0); |
704 case 7: | 713 case 7: |
705 return gfx::Vector2d(-kWheelScrollAmount, 0); | 714 return gfx::Vector2d(horizontal_scroll_class ? 0 : -kWheelScrollAmount, |
| 715 0); |
706 default: | 716 default: |
707 return gfx::Vector2d(); | 717 return gfx::Vector2d(); |
708 } | 718 } |
709 } | 719 } |
710 | 720 |
711 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { | 721 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { |
712 if (!event || event->type == GenericEvent) | 722 if (!event || event->type == GenericEvent) |
713 return NULL; | 723 return NULL; |
714 XEvent* copy = new XEvent; | 724 XEvent* copy = new XEvent; |
715 *copy = *event; | 725 *copy = *event; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 force = 0.0; | 789 force = 0.0; |
780 return force; | 790 return force; |
781 } | 791 } |
782 | 792 |
783 bool GetScrollOffsets(const base::NativeEvent& native_event, | 793 bool GetScrollOffsets(const base::NativeEvent& native_event, |
784 float* x_offset, | 794 float* x_offset, |
785 float* y_offset, | 795 float* y_offset, |
786 float* x_offset_ordinal, | 796 float* x_offset_ordinal, |
787 float* y_offset_ordinal, | 797 float* y_offset_ordinal, |
788 int* finger_count) { | 798 int* finger_count) { |
789 if (!DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) | 799 if (DeviceDataManagerX11::GetInstance()->IsScrollEvent(native_event)) { |
790 return false; | 800 // Temp values to prevent passing NULLs to DeviceDataManager. |
| 801 float x_offset_, y_offset_; |
| 802 float x_offset_ordinal_, y_offset_ordinal_; |
| 803 int finger_count_; |
| 804 if (!x_offset) |
| 805 x_offset = &x_offset_; |
| 806 if (!y_offset) |
| 807 y_offset = &y_offset_; |
| 808 if (!x_offset_ordinal) |
| 809 x_offset_ordinal = &x_offset_ordinal_; |
| 810 if (!y_offset_ordinal) |
| 811 y_offset_ordinal = &y_offset_ordinal_; |
| 812 if (!finger_count) |
| 813 finger_count = &finger_count_; |
791 | 814 |
792 // Temp values to prevent passing NULLs to DeviceDataManager. | 815 DeviceDataManagerX11::GetInstance()->GetScrollOffsets( |
793 float x_offset_, y_offset_; | 816 native_event, x_offset, y_offset, x_offset_ordinal, y_offset_ordinal, |
794 float x_offset_ordinal_, y_offset_ordinal_; | 817 finger_count); |
795 int finger_count_; | 818 return true; |
796 if (!x_offset) | 819 } |
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 | 820 |
807 DeviceDataManagerX11::GetInstance()->GetScrollOffsets( | 821 if (DeviceDataManagerX11::GetInstance()->GetScrollClassEventDetail( |
808 native_event, | 822 native_event) != SCROLL_TYPE_NO_SCROLL) { |
809 x_offset, y_offset, | 823 double x_scroll_offset, y_scroll_offset; |
810 x_offset_ordinal, y_offset_ordinal, | 824 DeviceDataManagerX11::GetInstance()->GetScrollClassOffsets( |
811 finger_count); | 825 native_event, &x_scroll_offset, &y_scroll_offset); |
812 return true; | 826 *x_offset = x_scroll_offset * kWheelScrollAmount; |
| 827 *y_offset = y_scroll_offset * kWheelScrollAmount; |
| 828 return true; |
| 829 } |
| 830 return false; |
813 } | 831 } |
814 | 832 |
815 bool GetFlingData(const base::NativeEvent& native_event, | 833 bool GetFlingData(const base::NativeEvent& native_event, |
816 float* vx, | 834 float* vx, |
817 float* vy, | 835 float* vy, |
818 float* vx_ordinal, | 836 float* vx_ordinal, |
819 float* vy_ordinal, | 837 float* vy_ordinal, |
820 bool* is_cancel) { | 838 bool* is_cancel) { |
821 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event)) | 839 if (!DeviceDataManagerX11::GetInstance()->IsFlingEvent(native_event)) |
822 return false; | 840 return false; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 xievent->detail = | 901 xievent->detail = |
884 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); | 902 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); |
885 break; | 903 break; |
886 } | 904 } |
887 default: | 905 default: |
888 break; | 906 break; |
889 } | 907 } |
890 } | 908 } |
891 | 909 |
892 } // namespace ui | 910 } // namespace ui |
OLD | NEW |