Chromium Code Reviews| 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 <cmath> | 7 #include <cmath> |
| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 } | 437 } |
| 438 case XI_Motion: { | 438 case XI_Motion: { |
| 439 bool is_cancel; | 439 bool is_cancel; |
| 440 DeviceDataManagerX11* devices = DeviceDataManagerX11::GetInstance(); | 440 DeviceDataManagerX11* devices = DeviceDataManagerX11::GetInstance(); |
| 441 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) | 441 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) |
| 442 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; | 442 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; |
| 443 if (devices->IsScrollEvent(native_event)) { | 443 if (devices->IsScrollEvent(native_event)) { |
| 444 return devices->IsTouchpadXInputEvent(native_event) ? ET_SCROLL | 444 return devices->IsTouchpadXInputEvent(native_event) ? ET_SCROLL |
| 445 : ET_MOUSEWHEEL; | 445 : ET_MOUSEWHEEL; |
| 446 } | 446 } |
| 447 if (devices->IsScrollClassEvent(native_event)) { | |
| 448 return ET_MOUSEWHEEL; | |
| 449 } | |
|
sadrul
2014/12/22 17:11:12
no {}
| |
| 447 if (devices->IsCMTMetricsEvent(native_event)) | 450 if (devices->IsCMTMetricsEvent(native_event)) |
| 448 return ET_UMA_DATA; | 451 return ET_UMA_DATA; |
| 449 if (GetButtonMaskForX2Event(xievent)) | 452 if (GetButtonMaskForX2Event(xievent)) |
| 450 return ET_MOUSE_DRAGGED; | 453 return ET_MOUSE_DRAGGED; |
| 451 return ET_MOUSE_MOVED; | 454 return ET_MOUSE_MOVED; |
| 452 } | 455 } |
| 453 case XI_KeyPress: | 456 case XI_KeyPress: |
| 454 return ET_KEY_PRESSED; | 457 return ET_KEY_PRESSED; |
| 455 case XI_KeyRelease: | 458 case XI_KeyRelease: |
| 456 return ET_KEY_RELEASED; | 459 return ET_KEY_RELEASED; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 } | 712 } |
| 710 | 713 |
| 711 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { | 714 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { |
| 712 float x_offset, y_offset; | 715 float x_offset, y_offset; |
| 713 if (GetScrollOffsets( | 716 if (GetScrollOffsets( |
| 714 native_event, &x_offset, &y_offset, NULL, NULL, NULL)) { | 717 native_event, &x_offset, &y_offset, NULL, NULL, NULL)) { |
| 715 return gfx::Vector2d(static_cast<int>(x_offset), | 718 return gfx::Vector2d(static_cast<int>(x_offset), |
| 716 static_cast<int>(y_offset)); | 719 static_cast<int>(y_offset)); |
| 717 } | 720 } |
| 718 | 721 |
| 722 double x_scroll_offset, y_scroll_offset; | |
| 723 if (DeviceDataManagerX11::GetInstance()->IsScrollClassEvent(native_event)) { | |
| 724 DeviceDataManagerX11::GetInstance()->GetScrollClassOffsets( | |
| 725 native_event, | |
| 726 &x_scroll_offset, &y_scroll_offset); | |
| 727 return gfx::Vector2d( | |
| 728 static_cast<int>(x_scroll_offset * kWheelScrollAmount), | |
| 729 static_cast<int>(y_scroll_offset * kWheelScrollAmount)); | |
| 730 } | |
| 731 | |
|
sadrul
2014/12/22 17:11:12
Can this block move into GetScrollOffsets() instea
| |
| 719 int button = native_event->type == GenericEvent ? | 732 int button = native_event->type == GenericEvent ? |
| 720 EventButtonFromNative(native_event) : native_event->xbutton.button; | 733 EventButtonFromNative(native_event) : native_event->xbutton.button; |
| 721 | 734 |
| 735 bool verticalScrollClass = | |
| 736 DeviceDataManagerX11::GetInstance() | |
| 737 ->IsScrollClassVerticalDevice(native_event); | |
| 738 bool horizontalScrollClass = | |
|
sadrul
2014/12/22 17:11:12
Should be vertical_scroll_class etc.
| |
| 739 DeviceDataManagerX11::GetInstance() | |
| 740 ->IsScrollClassHorizontalDevice(native_event); | |
| 741 | |
| 722 switch (button) { | 742 switch (button) { |
| 723 case 4: | 743 case 4: |
| 724 return gfx::Vector2d(0, kWheelScrollAmount); | 744 return gfx::Vector2d(0, verticalScrollClass ? 0 : kWheelScrollAmount); |
| 725 case 5: | 745 case 5: |
| 726 return gfx::Vector2d(0, -kWheelScrollAmount); | 746 return gfx::Vector2d(0, verticalScrollClass ? 0 : -kWheelScrollAmount); |
| 727 case 6: | 747 case 6: |
| 728 return gfx::Vector2d(kWheelScrollAmount, 0); | 748 return gfx::Vector2d(horizontalScrollClass ? 0 : kWheelScrollAmount, 0); |
| 729 case 7: | 749 case 7: |
| 730 return gfx::Vector2d(-kWheelScrollAmount, 0); | 750 return gfx::Vector2d(horizontalScrollClass ? 0 : -kWheelScrollAmount, 0); |
| 731 default: | 751 default: |
| 732 return gfx::Vector2d(); | 752 return gfx::Vector2d(); |
| 733 } | 753 } |
| 734 } | 754 } |
| 735 | 755 |
| 736 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { | 756 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { |
| 737 if (!event || event->type == GenericEvent) | 757 if (!event || event->type == GenericEvent) |
| 738 return NULL; | 758 return NULL; |
| 739 XEvent* copy = new XEvent; | 759 XEvent* copy = new XEvent; |
| 740 *copy = *event; | 760 *copy = *event; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 920 xievent->detail = | 940 xievent->detail = |
| 921 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); | 941 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); |
| 922 break; | 942 break; |
| 923 } | 943 } |
| 924 default: | 944 default: |
| 925 break; | 945 break; |
| 926 } | 946 } |
| 927 } | 947 } |
| 928 | 948 |
| 929 } // namespace ui | 949 } // namespace ui |
| OLD | NEW |