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 | |
736 int GetChangedMouseButtonFlagsFromNative( | 688 int GetChangedMouseButtonFlagsFromNative( |
737 const base::NativeEvent& native_event) { | 689 const base::NativeEvent& native_event) { |
738 switch (native_event->type) { | 690 switch (native_event->type) { |
739 case ButtonPress: | 691 case ButtonPress: |
740 case ButtonRelease: | 692 case ButtonRelease: |
741 return GetEventFlagsFromXState(native_event->xbutton.state); | 693 return GetEventFlagsFromXState(native_event->xbutton.state); |
742 case GenericEvent: { | 694 case GenericEvent: { |
743 XIDeviceEvent* xievent = | 695 XIDeviceEvent* xievent = |
744 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | 696 static_cast<XIDeviceEvent*>(native_event->xcookie.data); |
745 switch (xievent->evtype) { | 697 switch (xievent->evtype) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 xievent->detail = | 920 xievent->detail = |
969 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); | 921 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); |
970 break; | 922 break; |
971 } | 923 } |
972 default: | 924 default: |
973 break; | 925 break; |
974 } | 926 } |
975 } | 927 } |
976 | 928 |
977 } // namespace ui | 929 } // namespace ui |
OLD | NEW |