| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 int GetEventFlagsFromXKeyEvent(XEvent* xevent) { | 155 int GetEventFlagsFromXKeyEvent(XEvent* xevent) { |
| 156 DCHECK(xevent->type == KeyPress || xevent->type == KeyRelease); | 156 DCHECK(xevent->type == KeyPress || xevent->type == KeyRelease); |
| 157 | 157 |
| 158 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
| 159 const int ime_fabricated_flag = 0; | 159 const int ime_fabricated_flag = 0; |
| 160 #else | 160 #else |
| 161 // XIM fabricates key events for the character compositions by XK_Multi_key. | 161 // XIM fabricates key events for the character compositions by XK_Multi_key. |
| 162 // For example, when a user hits XK_Multi_key, XK_apostrophe, and XK_e in | 162 // For example, when a user hits XK_Multi_key, XK_apostrophe, and XK_e in |
| 163 // order to input "é", then XIM generates a key event with keycode=0 and | 163 // order to input "é", then XIM generates a key event with keycode=0 and |
| 164 // state=0 for the composition, and the sequence of X11 key events will be | 164 // state=0 for the composition, and the sequence of X11 key events will be |
| 165 // XK_Multi_key, XK_apostrophe, **NoSymbol**, and XK_e. | 165 // XK_Multi_key, XK_apostrophe, **NoSymbol**, and XK_e. If the user used |
| 166 // shift key and/or caps lock key, state can be ShiftMask, LockMask or both. |
| 166 // | 167 // |
| 167 // We have to send these fabricated key events to XIM so it can correctly | 168 // We have to send these fabricated key events to XIM so it can correctly |
| 168 // handle the character compositions. | 169 // handle the character compositions. |
| 170 const unsigned int shift_lock_mask = ShiftMask | LockMask; |
| 169 const bool fabricated_by_xim = | 171 const bool fabricated_by_xim = |
| 170 xevent->xkey.keycode == 0 && xevent->xkey.state == 0; | 172 xevent->xkey.keycode == 0 && |
| 173 (xevent->xkey.state & ~shift_lock_mask) == 0; |
| 171 const int ime_fabricated_flag = | 174 const int ime_fabricated_flag = |
| 172 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0; | 175 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0; |
| 173 #endif | 176 #endif |
| 174 | 177 |
| 175 return GetEventFlagsFromXState(xevent->xkey.state) | | 178 return GetEventFlagsFromXState(xevent->xkey.state) | |
| 176 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) | | 179 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) | |
| 177 (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ? | 180 (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ? |
| 178 ui::EF_FUNCTION_KEY : 0) | | 181 ui::EF_FUNCTION_KEY : 0) | |
| 179 ime_fabricated_flag; | 182 ime_fabricated_flag; |
| 180 } | 183 } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 DeviceDataManager::GetInstance()->GetGestureTimes( | 724 DeviceDataManager::GetInstance()->GetGestureTimes( |
| 722 native_event, start_time, end_time); | 725 native_event, start_time, end_time); |
| 723 return true; | 726 return true; |
| 724 } | 727 } |
| 725 | 728 |
| 726 bool IsTouchpadEvent(const base::NativeEvent& event) { | 729 bool IsTouchpadEvent(const base::NativeEvent& event) { |
| 727 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); | 730 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); |
| 728 } | 731 } |
| 729 | 732 |
| 730 } // namespace ui | 733 } // namespace ui |
| OLD | NEW |