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/base/events.h" | 5 #include "ui/base/events.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 // Drop wheel events; we should've already scrolled on the press. | 677 // Drop wheel events; we should've already scrolled on the press. |
678 if (button >= kMinWheelButton && button <= kMaxWheelButton) | 678 if (button >= kMinWheelButton && button <= kMaxWheelButton) |
679 return ET_UNKNOWN; | 679 return ET_UNKNOWN; |
680 return ET_MOUSE_RELEASED; | 680 return ET_MOUSE_RELEASED; |
681 } | 681 } |
682 case XI_Motion: { | 682 case XI_Motion: { |
683 float vx, vy; | 683 float vx, vy; |
684 bool is_cancel; | 684 bool is_cancel; |
685 if (GetFlingData(native_event, &vx, &vy, &is_cancel)) { | 685 if (GetFlingData(native_event, &vx, &vy, &is_cancel)) { |
686 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; | 686 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; |
687 } else if (GetScrollOffsets(native_event, NULL, NULL)) | 687 } else if (GetScrollOffsets(native_event, NULL, NULL)) { |
688 return ET_SCROLL; | 688 return ET_SCROLL; |
689 else if (GetButtonMaskForX2Event(xievent)) { | 689 } else if (GetButtonMaskForX2Event(xievent)) { |
690 return ET_MOUSE_DRAGGED; | 690 return ET_MOUSE_DRAGGED; |
691 } else | 691 } else { |
692 return ET_MOUSE_MOVED; | 692 return ET_MOUSE_MOVED; |
| 693 } |
693 } | 694 } |
694 } | 695 } |
695 } | 696 } |
696 default: | 697 default: |
697 break; | 698 break; |
698 } | 699 } |
699 return ET_UNKNOWN; | 700 return ET_UNKNOWN; |
700 } | 701 } |
701 | 702 |
702 int EventFlagsFromNative(const base::NativeEvent& native_event) { | 703 int EventFlagsFromNative(const base::NativeEvent& native_event) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 double y = xievent->event_y; | 828 double y = xievent->event_y; |
828 if (XIMaskIsSet(xievent->valuators.mask, 1)) | 829 if (XIMaskIsSet(xievent->valuators.mask, 1)) |
829 y = *valuators++ - (xievent->root_y - xievent->event_y); | 830 y = *valuators++ - (xievent->root_y - xievent->event_y); |
830 | 831 |
831 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); | 832 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); |
832 } | 833 } |
833 } | 834 } |
834 return gfx::Point(); | 835 return gfx::Point(); |
835 } | 836 } |
836 | 837 |
| 838 gfx::Point EventSystemLocationFromNative( |
| 839 const base::NativeEvent& native_event) { |
| 840 switch (native_event->type) { |
| 841 case ButtonPress: |
| 842 case ButtonRelease: { |
| 843 return gfx::Point(native_event->xbutton.x_root, |
| 844 native_event->xbutton.y_root); |
| 845 } |
| 846 case MotionNotify: { |
| 847 return gfx::Point(native_event->xmotion.x_root, |
| 848 native_event->xmotion.y_root); |
| 849 } |
| 850 case GenericEvent: { |
| 851 XIDeviceEvent* xievent = |
| 852 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 853 return gfx::Point(xievent->root_x, xievent->root_y); |
| 854 } |
| 855 } |
| 856 |
| 857 return gfx::Point(); |
| 858 } |
| 859 |
837 int EventButtonFromNative(const base::NativeEvent& native_event) { | 860 int EventButtonFromNative(const base::NativeEvent& native_event) { |
838 CHECK_EQ(GenericEvent, native_event->type); | 861 CHECK_EQ(GenericEvent, native_event->type); |
839 XIDeviceEvent* xievent = | 862 XIDeviceEvent* xievent = |
840 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 863 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
841 int button = xievent->detail; | 864 int button = xievent->detail; |
842 | 865 |
843 return (xievent->sourceid == xievent->deviceid) ? | 866 return (xievent->sourceid == xievent->deviceid) ? |
844 ui::GetMappedButton(button) : button; | 867 ui::GetMappedButton(button) : button; |
845 } | 868 } |
846 | 869 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 noop->xclient.format = 8; | 1034 noop->xclient.format = 8; |
1012 DCHECK(!noop->xclient.display); | 1035 DCHECK(!noop->xclient.display); |
1013 } | 1036 } |
1014 // Make sure we use atom from current xdisplay, which may | 1037 // Make sure we use atom from current xdisplay, which may |
1015 // change during the test. | 1038 // change during the test. |
1016 noop->xclient.message_type = GetNoopEventAtom(); | 1039 noop->xclient.message_type = GetNoopEventAtom(); |
1017 return noop; | 1040 return noop; |
1018 } | 1041 } |
1019 | 1042 |
1020 } // namespace ui | 1043 } // namespace ui |
OLD | NEW |