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/events/event_constants.h" | 5 #include "ui/events/event_constants.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 KeySym keysym = XK_VoidSymbol; | 678 KeySym keysym = XK_VoidSymbol; |
679 if (xkey) | 679 if (xkey) |
680 XLookupString(xkey, NULL, 0, &keysym, NULL); | 680 XLookupString(xkey, NULL, 0, &keysym, NULL); |
681 return keysym; | 681 return keysym; |
682 } | 682 } |
683 | 683 |
684 bool IsCharFromNative(const base::NativeEvent& native_event) { | 684 bool IsCharFromNative(const base::NativeEvent& native_event) { |
685 return false; | 685 return false; |
686 } | 686 } |
687 | 687 |
| 688 uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) { |
| 689 int windows_key_code = ui::KeyboardCodeFromXKeyEvent(native_event); |
| 690 if (windows_key_code == ui::VKEY_SHIFT || |
| 691 windows_key_code == ui::VKEY_CONTROL || |
| 692 windows_key_code == ui::VKEY_MENU) { |
| 693 // To support DOM3 'location' attribute, we need to lookup an X KeySym and |
| 694 // set ui::VKEY_[LR]XXX instead of ui::VKEY_XXX. |
| 695 KeySym keysym = XK_VoidSymbol; |
| 696 XLookupString(&native_event->xkey, NULL, 0, &keysym, NULL); |
| 697 switch (keysym) { |
| 698 case XK_Shift_L: |
| 699 return ui::VKEY_LSHIFT; |
| 700 case XK_Shift_R: |
| 701 return ui::VKEY_RSHIFT; |
| 702 case XK_Control_L: |
| 703 return ui::VKEY_LCONTROL; |
| 704 case XK_Control_R: |
| 705 return ui::VKEY_RCONTROL; |
| 706 case XK_Meta_L: |
| 707 case XK_Alt_L: |
| 708 return ui::VKEY_LMENU; |
| 709 case XK_Meta_R: |
| 710 case XK_Alt_R: |
| 711 return ui::VKEY_RMENU; |
| 712 } |
| 713 } |
| 714 return windows_key_code; |
| 715 } |
| 716 |
| 717 uint16 TextFromNative(const base::NativeEvent& native_event) { |
| 718 int flags = EventFlagsFromNative(native_event); |
| 719 if ((flags & ui::EF_CONTROL_DOWN) != 0) { |
| 720 int windows_key_code = WindowsKeycodeFromNative(native_event); |
| 721 return ui::GetControlCharacterForKeycode(windows_key_code, |
| 722 flags & ui::EF_SHIFT_DOWN); |
| 723 } |
| 724 |
| 725 return UnmodifiedTextFromNative(native_event); |
| 726 } |
| 727 |
| 728 uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) { |
| 729 uint32 keycode = WindowsKeycodeFromNative(native_event); |
| 730 if (keycode == ui::VKEY_RETURN) |
| 731 return '\r'; |
| 732 else |
| 733 return ui::GetCharacterFromXEvent(native_event); |
| 734 } |
| 735 |
688 int GetChangedMouseButtonFlagsFromNative( | 736 int GetChangedMouseButtonFlagsFromNative( |
689 const base::NativeEvent& native_event) { | 737 const base::NativeEvent& native_event) { |
690 switch (native_event->type) { | 738 switch (native_event->type) { |
691 case ButtonPress: | 739 case ButtonPress: |
692 case ButtonRelease: | 740 case ButtonRelease: |
693 return GetEventFlagsFromXState(native_event->xbutton.state); | 741 return GetEventFlagsFromXState(native_event->xbutton.state); |
694 case GenericEvent: { | 742 case GenericEvent: { |
695 XIDeviceEvent* xievent = | 743 XIDeviceEvent* xievent = |
696 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 744 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
697 switch (xievent->evtype) { | 745 switch (xievent->evtype) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 xievent->detail = | 968 xievent->detail = |
921 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); | 969 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); |
922 break; | 970 break; |
923 } | 971 } |
924 default: | 972 default: |
925 break; | 973 break; |
926 } | 974 } |
927 } | 975 } |
928 | 976 |
929 } // namespace ui | 977 } // namespace ui |
OLD | NEW |