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 KeySym keysym; | 582 XKeyEvent* xkey = NULL; |
583 XLookupString(&native_event->xkey, NULL, 0, &keysym, NULL); | 583 XEvent xkey_from_xi2; |
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 default: | |
600 break; | |
sadrul
2014/07/17 16:14:34
NOTREACHED()?
kpschoedel
2014/07/17 17:01:45
Done.
| |
601 } | |
602 } | |
603 default: | |
604 break; | |
sadrul
2014/07/17 16:14:34
NOTREACHED()?
kpschoedel
2014/07/17 17:01:45
Done.
| |
605 } | |
606 KeySym keysym = XK_VoidSymbol; | |
607 if (xkey) | |
608 XLookupString(xkey, NULL, 0, &keysym, NULL); | |
584 return keysym; | 609 return keysym; |
585 } | 610 } |
586 | 611 |
587 int GetChangedMouseButtonFlagsFromNative( | 612 int GetChangedMouseButtonFlagsFromNative( |
588 const base::NativeEvent& native_event) { | 613 const base::NativeEvent& native_event) { |
589 switch (native_event->type) { | 614 switch (native_event->type) { |
590 case ButtonPress: | 615 case ButtonPress: |
591 case ButtonRelease: | 616 case ButtonRelease: |
592 return GetEventFlagsFromXState(native_event->xbutton.state); | 617 return GetEventFlagsFromXState(native_event->xbutton.state); |
593 case GenericEvent: { | 618 case GenericEvent: { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 DeviceDataManagerX11::GetInstance()->GetGestureTimes( | 800 DeviceDataManagerX11::GetInstance()->GetGestureTimes( |
776 native_event, start_time, end_time); | 801 native_event, start_time, end_time); |
777 return true; | 802 return true; |
778 } | 803 } |
779 | 804 |
780 bool IsTouchpadEvent(const base::NativeEvent& event) { | 805 bool IsTouchpadEvent(const base::NativeEvent& event) { |
781 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); | 806 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); |
782 } | 807 } |
783 | 808 |
784 } // namespace ui | 809 } // namespace ui |
OLD | NEW |