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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 double y = xievent->event_y; | 824 double y = xievent->event_y; |
824 if (XIMaskIsSet(xievent->valuators.mask, 1)) | 825 if (XIMaskIsSet(xievent->valuators.mask, 1)) |
825 y = *valuators++ - (xievent->root_y - xievent->event_y); | 826 y = *valuators++ - (xievent->root_y - xievent->event_y); |
826 | 827 |
827 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); | 828 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); |
828 } | 829 } |
829 } | 830 } |
830 return gfx::Point(); | 831 return gfx::Point(); |
831 } | 832 } |
832 | 833 |
| 834 gfx::Point EventSystemLocationFromNative( |
| 835 const base::NativeEvent& native_event) { |
| 836 switch (native_event->type) { |
| 837 case ButtonPress: |
| 838 case ButtonRelease: { |
| 839 return gfx::Point(native_event->xbutton.x_root, |
| 840 native_event->xbutton.y_root); |
| 841 } |
| 842 case MotionNotify: { |
| 843 return gfx::Point(native_event->xmotion.x_root, |
| 844 native_event->xmotion.y_root); |
| 845 } |
| 846 case GenericEvent: { |
| 847 XIDeviceEvent* xievent = |
| 848 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 849 return gfx::Point(xievent->root_x, xievent->root_y); |
| 850 } |
| 851 } |
| 852 |
| 853 return gfx::Point(); |
| 854 } |
| 855 |
833 int EventButtonFromNative(const base::NativeEvent& native_event) { | 856 int EventButtonFromNative(const base::NativeEvent& native_event) { |
834 CHECK_EQ(GenericEvent, native_event->type); | 857 CHECK_EQ(GenericEvent, native_event->type); |
835 XIDeviceEvent* xievent = | 858 XIDeviceEvent* xievent = |
836 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 859 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
837 int button = xievent->detail; | 860 int button = xievent->detail; |
838 | 861 |
839 return (xievent->sourceid == xievent->deviceid) ? | 862 return (xievent->sourceid == xievent->deviceid) ? |
840 ui::GetMappedButton(button) : button; | 863 ui::GetMappedButton(button) : button; |
841 } | 864 } |
842 | 865 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 noop->xclient.format = 8; | 1030 noop->xclient.format = 8; |
1008 DCHECK(!noop->xclient.display); | 1031 DCHECK(!noop->xclient.display); |
1009 } | 1032 } |
1010 // Make sure we use atom from current xdisplay, which may | 1033 // Make sure we use atom from current xdisplay, which may |
1011 // change during the test. | 1034 // change during the test. |
1012 noop->xclient.message_type = GetNoopEventAtom(); | 1035 noop->xclient.message_type = GetNoopEventAtom(); |
1013 return noop; | 1036 return noop; |
1014 } | 1037 } |
1015 | 1038 |
1016 } // namespace ui | 1039 } // namespace ui |
OLD | NEW |