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