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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 case XI_Motion: | 751 case XI_Motion: |
752 return GetButtonMaskForX2Event(xievent) | | 752 return GetButtonMaskForX2Event(xievent) | |
753 GetEventFlagsFromXState(xievent->mods.effective); | 753 GetEventFlagsFromXState(xievent->mods.effective); |
754 } | 754 } |
755 } | 755 } |
756 } | 756 } |
757 return 0; | 757 return 0; |
758 } | 758 } |
759 | 759 |
760 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { | 760 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { |
| 761 // Synthetic events don't have native events. |
| 762 if (!native_event) |
| 763 return base::TimeDelta(); |
| 764 |
761 switch(native_event->type) { | 765 switch(native_event->type) { |
762 case KeyPress: | 766 case KeyPress: |
763 case KeyRelease: | 767 case KeyRelease: |
764 return base::TimeDelta::FromMilliseconds(native_event->xkey.time); | 768 return base::TimeDelta::FromMilliseconds(native_event->xkey.time); |
765 case ButtonPress: | 769 case ButtonPress: |
766 case ButtonRelease: | 770 case ButtonRelease: |
767 return base::TimeDelta::FromMilliseconds(native_event->xbutton.time); | 771 return base::TimeDelta::FromMilliseconds(native_event->xbutton.time); |
768 break; | 772 break; |
769 case MotionNotify: | 773 case MotionNotify: |
770 return base::TimeDelta::FromMilliseconds(native_event->xmotion.time); | 774 return base::TimeDelta::FromMilliseconds(native_event->xmotion.time); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 noop->xclient.format = 8; | 988 noop->xclient.format = 8; |
985 DCHECK(!noop->xclient.display); | 989 DCHECK(!noop->xclient.display); |
986 } | 990 } |
987 // Make sure we use atom from current xdisplay, which may | 991 // Make sure we use atom from current xdisplay, which may |
988 // change during the test. | 992 // change during the test. |
989 noop->xclient.message_type = GetNoopEventAtom(); | 993 noop->xclient.message_type = GetNoopEventAtom(); |
990 return noop; | 994 return noop; |
991 } | 995 } |
992 | 996 |
993 } // namespace ui | 997 } // namespace ui |
OLD | NEW |