| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // handle the character compositions. | 182 // handle the character compositions. |
| 183 const unsigned int shift_lock_mask = ShiftMask | LockMask; | 183 const unsigned int shift_lock_mask = ShiftMask | LockMask; |
| 184 const bool fabricated_by_xim = | 184 const bool fabricated_by_xim = |
| 185 xevent->xkey.keycode == 0 && | 185 xevent->xkey.keycode == 0 && |
| 186 (xevent->xkey.state & ~shift_lock_mask) == 0; | 186 (xevent->xkey.state & ~shift_lock_mask) == 0; |
| 187 const int ime_fabricated_flag = | 187 const int ime_fabricated_flag = |
| 188 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0; | 188 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0; |
| 189 #endif | 189 #endif |
| 190 | 190 |
| 191 return GetEventFlagsFromXState(xevent->xkey.state) | | 191 return GetEventFlagsFromXState(xevent->xkey.state) | |
| 192 (xevent->xkey.send_event ? ui::EF_FINAL : 0) | |
| 192 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) | | 193 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) | |
| 193 (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ? | 194 (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ? |
| 194 ui::EF_FUNCTION_KEY : 0) | | 195 ui::EF_FUNCTION_KEY : 0) | |
| 195 ime_fabricated_flag; | 196 ime_fabricated_flag; |
| 196 } | 197 } |
| 197 | 198 |
| 198 int GetEventFlagsFromXGenericEvent(XEvent* xevent) { | 199 int GetEventFlagsFromXGenericEvent(XEvent* xevent) { |
| 199 DCHECK(xevent->type == GenericEvent); | 200 DCHECK(xevent->type == GenericEvent); |
| 200 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); | 201 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); |
| 201 DCHECK((xievent->evtype == XI_KeyPress) || | 202 DCHECK((xievent->evtype == XI_KeyPress) || |
| 202 (xievent->evtype == XI_KeyRelease)); | 203 (xievent->evtype == XI_KeyRelease)); |
| 203 return GetEventFlagsFromXState(xievent->mods.effective) | | 204 return GetEventFlagsFromXState(xievent->mods.effective) | |
| 205 (xevent->xkey.send_event ? ui::EF_FINAL : 0) | |
| 204 (IsKeypadKey( | 206 (IsKeypadKey( |
| 205 XkbKeycodeToKeysym(xievent->display, xievent->detail, 0, 0)) | 207 XkbKeycodeToKeysym(xievent->display, xievent->detail, 0, 0)) |
| 206 ? ui::EF_NUMPAD_KEY | 208 ? ui::EF_NUMPAD_KEY |
| 207 : 0); | 209 : 0); |
| 208 } | 210 } |
| 209 | 211 |
| 210 // Get the event flag for the button in XButtonEvent. During a ButtonPress | 212 // Get the event flag for the button in XButtonEvent. During a ButtonPress |
| 211 // event, |state| in XButtonEvent does not include the button that has just been | 213 // event, |state| in XButtonEvent does not include the button that has just been |
| 212 // pressed. Instead |state| contains flags for the buttons (if any) that had | 214 // pressed. Instead |state| contains flags for the buttons (if any) that had |
| 213 // already been pressed before the current button, and |button| stores the most | 215 // already been pressed before the current button, and |button| stores the most |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 DeviceDataManagerX11::GetInstance()->GetGestureTimes( | 777 DeviceDataManagerX11::GetInstance()->GetGestureTimes( |
| 776 native_event, start_time, end_time); | 778 native_event, start_time, end_time); |
| 777 return true; | 779 return true; |
| 778 } | 780 } |
| 779 | 781 |
| 780 bool IsTouchpadEvent(const base::NativeEvent& event) { | 782 bool IsTouchpadEvent(const base::NativeEvent& event) { |
| 781 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); | 783 return DeviceDataManagerX11::GetInstance()->IsTouchpadXInputEvent(event); |
| 782 } | 784 } |
| 783 | 785 |
| 784 } // namespace ui | 786 } // namespace ui |
| OLD | NEW |