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 <X11/Xlib.h> | 7 #include <X11/Xlib.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 <string.h> | 10 #include <string.h> |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 double y = xievent->event_y; | 772 double y = xievent->event_y; |
773 if (XIMaskIsSet(xievent->valuators.mask, 1)) | 773 if (XIMaskIsSet(xievent->valuators.mask, 1)) |
774 y = *valuators++ - (xievent->root_y - xievent->event_y); | 774 y = *valuators++ - (xievent->root_y - xievent->event_y); |
775 | 775 |
776 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); | 776 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); |
777 } | 777 } |
778 } | 778 } |
779 return gfx::Point(); | 779 return gfx::Point(); |
780 } | 780 } |
781 | 781 |
782 gfx::Point EventRootLocationFromNative(const base::NativeEvent& native_event) { | |
783 switch (native_event->type) { | |
784 case ButtonPress: | |
785 case ButtonRelease: | |
786 return gfx::Point(native_event->xbutton.x_root, | |
787 native_event->xbutton.y_root); | |
788 case MotionNotify: | |
789 return gfx::Point(native_event->xmotion.x_root, | |
790 native_event->xmotion.y_root); | |
791 case GenericEvent: { | |
792 XIDeviceEvent* xievent = | |
793 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | |
794 | |
795 // TODO(erg): This is significantly more simple than the above. Does this | |
796 // not handle an important case? | |
Elliot Glaysher
2012/05/09 19:39:18
attn derat/sadrul: this appears to work, but I don
Daniel Erat
2012/05/09 20:58:27
I don't think that you need to worry about valuato
| |
797 return gfx::Point(xievent->root_x, xievent->root_y); | |
798 } | |
799 } | |
800 | |
801 return gfx::Point(); | |
802 } | |
803 | |
782 int EventButtonFromNative(const base::NativeEvent& native_event) { | 804 int EventButtonFromNative(const base::NativeEvent& native_event) { |
783 CHECK_EQ(GenericEvent, native_event->type); | 805 CHECK_EQ(GenericEvent, native_event->type); |
784 XIDeviceEvent* xievent = | 806 XIDeviceEvent* xievent = |
785 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 807 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
786 int button = xievent->detail; | 808 int button = xievent->detail; |
787 | 809 |
788 return (xievent->sourceid == xievent->deviceid) ? | 810 return (xievent->sourceid == xievent->deviceid) ? |
789 ui::GetMappedButton(button) : button; | 811 ui::GetMappedButton(button) : button; |
790 } | 812 } |
791 | 813 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 noop->xclient.format = 8; | 953 noop->xclient.format = 8; |
932 DCHECK(!noop->xclient.display); | 954 DCHECK(!noop->xclient.display); |
933 } | 955 } |
934 // Make sure we use atom from current xdisplay, which may | 956 // Make sure we use atom from current xdisplay, which may |
935 // change during the test. | 957 // change during the test. |
936 noop->xclient.message_type = GetNoopEventAtom(); | 958 noop->xclient.message_type = GetNoopEventAtom(); |
937 return noop; | 959 return noop; |
938 } | 960 } |
939 | 961 |
940 } // namespace ui | 962 } // namespace ui |
OLD | NEW |