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 <algorithm> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/XKBlib.h> | 9 #include <X11/XKBlib.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 *error_msg = std::string(); | 183 *error_msg = std::string(); |
184 int x_key_code = KeyboardCodeToXKeyCode(key_code); | 184 int x_key_code = KeyboardCodeToXKeyCode(key_code); |
185 if (x_key_code == -1) { | 185 if (x_key_code == -1) { |
186 *text = std::string(); | 186 *text = std::string(); |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 XEvent event; | 190 XEvent event; |
191 memset(&event, 0, sizeof(XEvent)); | 191 memset(&event, 0, sizeof(XEvent)); |
192 XKeyEvent* key_event = &event.xkey; | 192 XKeyEvent* key_event = &event.xkey; |
193 Display* display = ui::GetXDisplay(); | 193 XDisplay* display = gfx::GetXDisplay(); |
194 if (!display) { | 194 if (!display) { |
195 *error_msg = | 195 *error_msg = |
196 "an X display is required for keycode conversions, consider using Xvfb"; | 196 "an X display is required for keycode conversions, consider using Xvfb"; |
197 *text = std::string(); | 197 *text = std::string(); |
198 return false; | 198 return false; |
199 } | 199 } |
200 key_event->display = display; | 200 key_event->display = display; |
201 key_event->keycode = x_key_code; | 201 key_event->keycode = x_key_code; |
202 if (modifiers & kShiftKeyModifierMask) | 202 if (modifiers & kShiftKeyModifierMask) |
203 key_event->state |= ShiftMask; | 203 key_event->state |= ShiftMask; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 found = true; | 260 found = true; |
261 break; | 261 break; |
262 } | 262 } |
263 } | 263 } |
264 if (found) { | 264 if (found) { |
265 *key_code = test_code; | 265 *key_code = test_code; |
266 *necessary_modifiers = test_modifiers; | 266 *necessary_modifiers = test_modifiers; |
267 } | 267 } |
268 return found; | 268 return found; |
269 } | 269 } |
OLD | NEW |