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/base/events/event_constants.h" | 5 #include "ui/base/events/event_constants.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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 } | 811 } |
| 812 break; | 812 break; |
| 813 } | 813 } |
| 814 } | 814 } |
| 815 NOTREACHED(); | 815 NOTREACHED(); |
| 816 return base::TimeDelta(); | 816 return base::TimeDelta(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 819 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
| 820 switch (native_event->type) { | 820 switch (native_event->type) { |
| 821 case EnterNotify: | |
| 822 case LeaveNotify: | |
| 823 return gfx::Point(native_event->xcrossing.x, native_event->xcrossing.y); | |
| 821 case ButtonPress: | 824 case ButtonPress: |
| 822 case ButtonRelease: | 825 case ButtonRelease: |
| 823 return gfx::Point(native_event->xbutton.x, native_event->xbutton.y); | 826 return gfx::Point(native_event->xbutton.x, native_event->xbutton.y); |
| 824 case MotionNotify: | 827 case MotionNotify: |
| 825 return gfx::Point(native_event->xmotion.x, native_event->xmotion.y); | 828 return gfx::Point(native_event->xmotion.x, native_event->xmotion.y); |
| 826 case GenericEvent: { | 829 case GenericEvent: { |
| 827 XIDeviceEvent* xievent = | 830 XIDeviceEvent* xievent = |
| 828 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 831 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 829 | 832 |
| 830 #if defined(USE_XI2_MT) | 833 #if defined(USE_XI2_MT) |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 860 return gfx::Point(); | 863 return gfx::Point(); |
| 861 } | 864 } |
| 862 | 865 |
| 863 gfx::Point EventSystemLocationFromNative( | 866 gfx::Point EventSystemLocationFromNative( |
| 864 const base::NativeEvent& native_event) { | 867 const base::NativeEvent& native_event) { |
| 865 switch (native_event->type) { | 868 switch (native_event->type) { |
| 866 case ButtonPress: | 869 case ButtonPress: |
| 867 case ButtonRelease: { | 870 case ButtonRelease: { |
| 868 return gfx::Point(native_event->xbutton.x_root, | 871 return gfx::Point(native_event->xbutton.x_root, |
| 869 native_event->xbutton.y_root); | 872 native_event->xbutton.y_root); |
| 870 } | 873 } |
|
sadrul
2012/10/02 21:44:16
Update for Leave/Enter here too?
oshima
2012/10/02 21:58:49
Done.
| |
| 871 case MotionNotify: { | 874 case MotionNotify: { |
| 872 return gfx::Point(native_event->xmotion.x_root, | 875 return gfx::Point(native_event->xmotion.x_root, |
| 873 native_event->xmotion.y_root); | 876 native_event->xmotion.y_root); |
| 874 } | 877 } |
| 875 case GenericEvent: { | 878 case GenericEvent: { |
| 876 XIDeviceEvent* xievent = | 879 XIDeviceEvent* xievent = |
| 877 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 880 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 878 return gfx::Point(xievent->root_x, xievent->root_y); | 881 return gfx::Point(xievent->root_x, xievent->root_y); |
| 879 } | 882 } |
| 880 } | 883 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 892 ui::GetMappedButton(button) : button; | 895 ui::GetMappedButton(button) : button; |
| 893 } | 896 } |
| 894 | 897 |
| 895 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | 898 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { |
| 896 return KeyboardCodeFromXKeyEvent(native_event); | 899 return KeyboardCodeFromXKeyEvent(native_event); |
| 897 } | 900 } |
| 898 | 901 |
| 899 bool IsMouseEvent(const base::NativeEvent& native_event) { | 902 bool IsMouseEvent(const base::NativeEvent& native_event) { |
| 900 if (native_event->type == ButtonPress || | 903 if (native_event->type == ButtonPress || |
| 901 native_event->type == ButtonRelease || | 904 native_event->type == ButtonRelease || |
| 902 native_event->type == MotionNotify) | 905 native_event->type == MotionNotify) |
|
sadrul
2012/10/02 21:44:16
ditto
oshima
2012/10/02 21:58:49
Done.
| |
| 903 return true; | 906 return true; |
| 904 if (native_event->type == GenericEvent) { | 907 if (native_event->type == GenericEvent) { |
| 905 XIDeviceEvent* xievent = | 908 XIDeviceEvent* xievent = |
| 906 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 909 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
| 907 return xievent->evtype == XI_ButtonPress || | 910 return xievent->evtype == XI_ButtonPress || |
| 908 xievent->evtype == XI_ButtonRelease || | 911 xievent->evtype == XI_ButtonRelease || |
| 909 xievent->evtype == XI_Motion; | 912 xievent->evtype == XI_Motion; |
| 910 } | 913 } |
| 911 return false; | 914 return false; |
| 912 } | 915 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 noop->xclient.format = 8; | 1062 noop->xclient.format = 8; |
| 1060 DCHECK(!noop->xclient.display); | 1063 DCHECK(!noop->xclient.display); |
| 1061 } | 1064 } |
| 1062 // Make sure we use atom from current xdisplay, which may | 1065 // Make sure we use atom from current xdisplay, which may |
| 1063 // change during the test. | 1066 // change during the test. |
| 1064 noop->xclient.message_type = GetNoopEventAtom(); | 1067 noop->xclient.message_type = GetNoopEventAtom(); |
| 1065 return noop; | 1068 return noop; |
| 1066 } | 1069 } |
| 1067 | 1070 |
| 1068 } // namespace ui | 1071 } // namespace ui |
| OLD | NEW |