| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/keycode_text_conversion.h" | 5 #include "chrome/test/chromedriver/keycode_text_conversion.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 #include <string.h> |
| 8 #include <X11/keysym.h> | 10 #include <X11/keysym.h> |
| 9 #include <X11/XKBlib.h> | 11 #include <X11/XKBlib.h> |
| 10 #include <X11/Xlib.h> | 12 #include <X11/Xlib.h> |
| 11 #include <X11/Xutil.h> | 13 #include <X11/Xutil.h> |
| 14 #include <algorithm> |
| 12 | 15 |
| 16 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/test/chromedriver/chrome/ui_events.h" | 18 #include "chrome/test/chromedriver/chrome/ui_events.h" |
| 15 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| 16 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 20 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 17 | 21 |
| 18 namespace { | 22 namespace { |
| 19 | 23 |
| 20 struct KeyCodeAndXKeyCode { | 24 struct KeyCodeAndXKeyCode { |
| 21 ui::KeyboardCode key_code; | 25 ui::KeyboardCode key_code; |
| 22 int x_key_code; | 26 int x_key_code; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 216 } |
| 213 if (modifiers & kMetaKeyModifierMask && | 217 if (modifiers & kMetaKeyModifierMask && |
| 214 GetXModifierMask(display, kMetaKeyModifierMask, &x_modifier)) { | 218 GetXModifierMask(display, kMetaKeyModifierMask, &x_modifier)) { |
| 215 key_event->state |= x_modifier; | 219 key_event->state |= x_modifier; |
| 216 } | 220 } |
| 217 if (modifiers & kNumLockKeyModifierMask && | 221 if (modifiers & kNumLockKeyModifierMask && |
| 218 GetXModifierMask(display, kNumLockKeyModifierMask, &x_modifier)) { | 222 GetXModifierMask(display, kNumLockKeyModifierMask, &x_modifier)) { |
| 219 key_event->state |= x_modifier; | 223 key_event->state |= x_modifier; |
| 220 } | 224 } |
| 221 key_event->type = KeyPress; | 225 key_event->type = KeyPress; |
| 222 uint16 character = ui::GetCharacterFromXEvent(&event); | 226 uint16_t character = ui::GetCharacterFromXEvent(&event); |
| 223 | 227 |
| 224 if (!character) | 228 if (!character) |
| 225 *text = std::string(); | 229 *text = std::string(); |
| 226 else | 230 else |
| 227 *text = base::UTF16ToUTF8(base::string16(1, character)); | 231 *text = base::UTF16ToUTF8(base::string16(1, character)); |
| 228 return true; | 232 return true; |
| 229 } | 233 } |
| 230 | 234 |
| 231 bool ConvertCharToKeyCode( | 235 bool ConvertCharToKeyCode( |
| 232 base::char16 key, | 236 base::char16 key, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 260 found = true; | 264 found = true; |
| 261 break; | 265 break; |
| 262 } | 266 } |
| 263 } | 267 } |
| 264 if (found) { | 268 if (found) { |
| 265 *key_code = test_code; | 269 *key_code = test_code; |
| 266 *necessary_modifiers = test_modifiers; | 270 *necessary_modifiers = test_modifiers; |
| 267 } | 271 } |
| 268 return found; | 272 return found; |
| 269 } | 273 } |
| OLD | NEW |