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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 572 |
573 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | 573 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { |
574 return KeyboardCodeFromXKeyEvent(native_event); | 574 return KeyboardCodeFromXKeyEvent(native_event); |
575 } | 575 } |
576 | 576 |
577 const char* CodeFromNative(const base::NativeEvent& native_event) { | 577 const char* CodeFromNative(const base::NativeEvent& native_event) { |
578 return CodeFromXEvent(native_event); | 578 return CodeFromXEvent(native_event); |
579 } | 579 } |
580 | 580 |
581 uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) { | 581 uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) { |
582 XKeyEvent* xkey = NULL; | 582 KeySym keysym; |
583 XEvent xkey_from_xi2; | 583 XLookupString(&native_event->xkey, NULL, 0, &keysym, NULL); |
584 switch (native_event->type) { | |
585 case KeyPress: | |
586 case KeyRelease: | |
587 xkey = &native_event->xkey; | |
588 break; | |
589 case GenericEvent: { | |
590 XIDeviceEvent* xievent = | |
591 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | |
592 switch (xievent->evtype) { | |
593 case XI_KeyPress: | |
594 case XI_KeyRelease: | |
595 // Build an XKeyEvent corresponding to the XI2 event, | |
596 // so that we can call XLookupString on it. | |
597 InitXKeyEventFromXIDeviceEvent(*native_event, &xkey_from_xi2); | |
598 xkey = &xkey_from_xi2.xkey; | |
599 break; | |
600 default: | |
601 NOTREACHED(); | |
602 break; | |
603 } | |
604 } | |
605 default: | |
606 NOTREACHED(); | |
607 break; | |
608 } | |
609 KeySym keysym = XK_VoidSymbol; | |
610 if (xkey) | |
611 XLookupString(xkey, NULL, 0, &keysym, NULL); | |
612 return keysym; | 584 return keysym; |
613 } | 585 } |
614 | 586 |
615 int GetChangedMouseButtonFlagsFromNative( | 587 int GetChangedMouseButtonFlagsFromNative( |
616 const base::NativeEvent& native_event) { | 588 const base::NativeEvent& native_event) { |
617 switch (native_event->type) { | 589 switch (native_event->type) { |
618 case ButtonPress: | 590 case ButtonPress: |
619 case ButtonRelease: | 591 case ButtonRelease: |
620 return GetEventFlagsFromXState(native_event->xbutton.state); | 592 return GetEventFlagsFromXState(native_event->xbutton.state); |
621 case GenericEvent: { | 593 case GenericEvent: { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 DeviceDataManagerX11::GetInstance()->GetGestureTimes( | 775 DeviceDataManagerX11::GetInstance()->GetGestureTimes( |
804 native_event, start_time, end_time); | 776 native_event, start_time, end_time); |
805 return true; | 777 return true; |
806 } | 778 } |
807 | 779 |
808 bool IsTouchpadEvent(const base::NativeEvent& event) { | 780 bool IsTouchpadEvent(const base::NativeEvent& event) { |
809 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); | 781 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); |
810 } | 782 } |
811 | 783 |
812 } // namespace ui | 784 } // namespace ui |
OLD | NEW |